forked from Chinlinlee/raccoon-dicom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-swagger.js
32 lines (29 loc) · 1.11 KB
/
get-swagger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const swaggerJsDoc = require("swagger-jsdoc");
const fsP = require("fs").promises;
(async () => {
const swaggerDefinition = {
info: {
// API informations (required)
title: "Raccoon", // Title (required)
version: "1.0.0", // Version (required)
description: "Raccoon API" // Description (optional)
},
openapi: "3.0.0"
};
// Options for the swagger docs
const options = {
// Import swaggerDefinitions
swaggerDefinition,
// Path to the API docs
// Note that this path is relative to the current directory from which the Node.js is ran, not the application itself.
apis: [
`${__dirname}/api/**/*.js`,
`${__dirname}/docs/swagger/parameters/*.yaml`,
`${__dirname}/docs/swagger/schemas/*.yaml`,
`${__dirname}/docs/swagger/responses/*.yaml`
]
};
const swaggerSpec = await swaggerJsDoc(options);
console.log(JSON.stringify(swaggerSpec, null, 4));
await fsP.writeFile("docs/swagger/openapi.json", JSON.stringify(swaggerSpec, null, 4));
})();