-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.js
More file actions
43 lines (40 loc) · 1.2 KB
/
swagger.js
File metadata and controls
43 lines (40 loc) · 1.2 KB
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
import swaggerAutogen from 'swagger-autogen'
const doc = {
swagger: "2.0",
info: {
version: "1.0.0",
title: "DoaPet",
description: "Documentação gerada automaticamente com swagger-autogen"
},
host: 'localhost:3000',
basePath: "/api",
schemes: ['https'],
consumes: ['application/json'],
produces: ['application/json'],
securityDefinitions: {
apiKeyAuth:{
type: "apiKey",
in: "header",
name: "access-token",
description: "Token de Acesso gerado após o login"
}
},
definitions: {
Erro: {
value: "Erro gerado pela aplicação",
msg: "Mensagem de erro",
param: "URL que gerou o erro"
}
}
}
const outputFile = './api/swagger/swagger_output.json'
const endpointsFiles = ['./api/index.js']
const options = {
swagger: '2.0', // By default is null
language: 'pt-BR', // By default is 'en-US'
disableLogs: false, // By default is false
disableWarnings: false // By default is false
}
swaggerAutogen(options)(outputFile, endpointsFiles, doc).then(async () => {
await import('./api/index.js');
});