-
Notifications
You must be signed in to change notification settings - Fork 0
/
swaggerAutegen.js
44 lines (41 loc) · 1.25 KB
/
swaggerAutegen.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
33
34
35
36
37
38
39
40
41
42
43
44
"use strict";
/* -------------------------------------------------------
EXPRESS - Personnel API
------------------------------------------------------- */
require("dotenv").config();
const HOST = process.env?.HOST || "127.0.0.1";
const PORT = process.env?.PORT || 8000;
/* ------------------------------------------------------- */
const swaggerAutogen = require("swagger-autogen")();
const packageJson = require("./package.json");
const document = {
info: {
version: packageJson.version,
title: packageJson.title,
description: packageJson.description,
termsOfService: "http://www.ucangun.com",
contact: { name: packageJson.author, email: process.env?.EMAIL },
license: { name: packageJson.license },
},
host: `${HOST}:${PORT}`,
basePath: "/",
schemes: ["http", "https"],
// JWT Settings:
securityDefinitions: {
JWT: {
type: "apiKey",
in: "header",
name: "Authorization",
description:
"Enter Your AccessToken (JWT) for Login. Example: <b>Bearer <i>...token...<i></b>",
},
},
security: [{ JWT: true }],
definition: {
// Schemas
},
};
const routes = ["./index.js"];
const outputFile = "./src/configs/swagger.json";
// Create JSON file:
swaggerAutogen(outputFile, routes, document);