-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathswagger.js
73 lines (69 loc) · 1.84 KB
/
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
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const swaggerAutogen = require('swagger-autogen')()
const doc = {
info: {
version: "1.0.0",
title: "My API",
description: "Documentation automatically generated by the <b>swagger-autogen</b> module."
},
host: "localhost:3000",
basePath: "/",
schemes: ['http', 'https'],
consumes: ['application/json'],
produces: ['application/json'],
tags: [
{
"name": "User",
"description": "Endpoints"
}
],
securityDefinitions: {
api_key: {
type: "apiKey",
name: "api_key",
in: "header"
},
petstore_auth: {
type: "oauth2",
authorizationUrl: "https://petstore.swagger.io/oauth/authorize",
flow: "implicit",
scopes: {
read_pets: "read your pets",
write_pets: "modify pets in your account"
}
}
},
definitions: {
Parents: {
father: "Simon Doe",
mother: "Marie Doe"
},
User: {
name: "Jhon Doe",
age: 29,
parents: {
$ref: '#/definitions/Parents'
},
diplomas: [
{
school: "XYZ University",
year: 2020,
completed: true,
internship: {
hours: 290,
location: "XYZ Company"
}
}
]
},
AddUser: {
$name: "Jhon Doe",
$age: 29,
about: ""
}
}
}
const outputFile = './swagger-output.json'
const endpointsFiles = ['./src/endpoints.js']
swaggerAutogen(outputFile, endpointsFiles, doc).then(() => {
require('./index') // Your project's root file
})