-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswagger.js
More file actions
93 lines (90 loc) · 2.79 KB
/
swagger.js
File metadata and controls
93 lines (90 loc) · 2.79 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const swaggerAutogen = require("swagger-autogen")()
const doc = {
info: {
version: "1.0.0",
title: "TechBlog (Video and News App) API",
description: "API for the tutorial on building mobile app using NodeJS."
},
host: "localhost:5000",
basePath: "/",
schemes: ["http", "https"],
consumes: ["application/json"],
produces: ["application/json"],
tags: [
{
"name": "Auth",
"description": "Auth endpoints"
},
{
"name": "Admin",
"description": "Admin endpoints"
},
{
"name": "Posts",
"description": "Posts endpoints"
},
{
"name": "Profile",
"description": "User profile endpoints"
},
],
securityDefinitions: {
Authorization: {
type: "apiKey",
name: "Authorization",
description: "Value: Bearer ",
in: "header",
scheme: 'bearer'
}
},
definitions: {
LoginModel: {
$email: "holaszyd2@gmail.com",
$password: "Password123#",
},
RegisterModel: {
$name: "John Snow",
$email: "holaszyd2@gmail.com",
$password: "Password123#",
},
UpdateUserModel: {
$name: "John Snow",
},
CategoryModel: {
$title: "Comedy",
},
StoryModel: {
$category: "6064e654b5c7475bac63ad22",
$title: "Elon Musk Admits He Wants to Travel to Mars Because No One Hates Him There Yet",
$body: "AUSTIN, Texas — Wiping tears from his eyes at a recent press conference, SpaceX CEO Elon Musk revealed that the reason he’s so keen on traveling to Mars is not for the potential benefits to science, but because it’s the one place he can think of where no one hates him yet.",
},
VideoModel: {
$videoId: "QWhJqvuB1ZA",
$title: "Welcome To America with Gad Elmaleh and Ron Livingston",
},
CommentModel: {
$story: "606576d16bb28e33ecf2872c",
$body: "That's very funny (:",
},
VerifyEmailModel: {
$code: 333333,
},
ChangePasswordModel: {
$oldPassword: "Password123#",
$newPassword: "Password789#",
},
ForgotPassWordModel: {
$email: "coommark@gmail.com",
},
ResetPasswordModel: {
$email: "holaszyd2@gmail.com",
$code: 999999,
$newPassword: "Password789#",
}
}
};
const outputFile = "./swagger_output.json";
const endpointFiles = ["./routes/index.js"];
swaggerAutogen(outputFile, endpointFiles, doc).then(() => {
require("./index");
});