forked from ALPHACamp/twitter-api-2020
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswagger.js
More file actions
50 lines (48 loc) · 1.22 KB
/
swagger.js
File metadata and controls
50 lines (48 loc) · 1.22 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
const swaggerAutogen = require('swagger-autogen')({ openapi: '3.0.0' })
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}
const doc = {
info: {
version: '1.0.0', // by default: "1.0.0"
title: 'Twitter API', // by default: "REST API"
description: '這是一個夢想的航道!' // by default: ""
},
host: process.env.HOST,
schemes: ['http', 'https'],
tags: [
{
name: 'Admin',
description: '後台管理者 router'
},
{
name: 'Users',
description: '使用者 router'
},
{
name: 'Tweets',
description: '推特 router'
},
{
name: 'Replies',
description: '回覆 router'
},
{
name: 'Followships',
description: '追蹤 router'
}
],
securityDefinitions: {
bearerAuth: {
type: 'apiKey',
in: 'header', // can be "header", "query" or "cookie"
name: 'Authorization', // name of the header, query parameter or cookie
description: 'Please enter a valid token to test the requests below...',
scheme: 'bearer',
bearerFormat: 'JWT'
}
}
}
const outputFile = './swagger-output.json'
const endpointsFiles = ['./app.js']
swaggerAutogen(outputFile, endpointsFiles, doc)