-
Notifications
You must be signed in to change notification settings - Fork 0
/
swaggerAutogen.js
57 lines (54 loc) · 1.77 KB
/
swaggerAutogen.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
45
46
47
48
49
50
51
52
53
54
55
56
57
"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.clarusway.com/#",
contact: { name: packageJson.author, email: "[email protected]" },
license: { name: packageJson.license, },
},
host: `${HOST}:${PORT}`,
basePath: '/',
schemes: ['http', 'https'],
consumes: ["application/json"],
produces: ["application/json"],
securityDefinitions: {
Token: {
type: 'apiKey',
in: 'header',
name: 'Authorization',
description: 'Simple Token Authentication * Example: <b>Token ...tokenKey...</b>'
},
Bearer: {
type: 'apiKey',
in: 'header',
name: 'Authorization',
description: 'JWT Authentication * Example: <b>Bearer ...accessToken...</b>'
},
},
security: [{ Token: [] }, { Bearer: [] }],
definition: {
// Models:
"User": require('./src/models/user').schema.obj,
"Brand": require('./src/models/brand').schema.obj,
"Category": require('./src/models/category').schema.obj,
"Firm": require('./src/models/firm').schema.obj,
"Product": require('./src/models/product').schema.obj,
"Purchase": require('./src/models/purchase').schema.obj,
"Sale": require('./src/models/sale').schema.obj,
}
}
const routes = ['./index.js']
const outputFile = './src/configs/swagger.json'
// Create JSON file:
swaggerAutogen(outputFile, routes, document)