-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.js
More file actions
69 lines (65 loc) · 1.98 KB
/
swagger.js
File metadata and controls
69 lines (65 loc) · 1.98 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
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
//per visionare la documentazione: http://localhost:3000/doc/
const swaggerAutogen = require('swagger-autogen')()
const outputFile = './swagger_output.json'
const endpointsFiles = ['./routes/stations.js', './routes/posts.js', './routes/users.js']
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'],
consumes: ['application/json'],
produces: ['application/json'],
tags: [
{
"name": "Post",
"description": "Endpoints"
},
{
"name": "Station",
"description": "Endpoints"
},
{
"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: {
Post: {
$title: "this is the title of my post",
$description: "this is the description of my post"
},
Station: {
$name: "Central Park",
$location: { type: "Point", coordinates: [ -73.97, 40.77 ] }
},
User: {
$username: "username",
$password: "password",
$role: { type: "Admin", }
}
}
}
//swaggerAutogen(outputFile, endpointsFiles) if you want not to execute every time that you run the project
swaggerAutogen(outputFile, endpointsFiles, doc).then(() => {
require('./app.js')
})