forked from davibaltar/example-swagger-autogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-docs.js
66 lines (65 loc) · 1.39 KB
/
api-docs.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
import swagger_autogen from 'swagger-autogen'
const outputFile = './swagger-output.json'
await swagger_autogen(outputFile, ['./src/endpoints.js'], {
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: ""
}
}
})