-
Notifications
You must be signed in to change notification settings - Fork 1
/
swagger.js
64 lines (61 loc) · 1.57 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
const swaggerAutogen = require("swagger-autogen")();
const doc = {
info: {
version: "1.0.0",
title: "ok-blogger backend API",
description: "This is the documentation for backend server API.",
},
host: "ok-blogger.herokuapp.com",
basePath: "/",
consumes: ["application/json"],
produces: ["application/json"],
schemes: ["https"],
securityDefinitions: {
apiKeyAuth: {
type: "apiKey",
in: "header", // can be "header", "query" or "cookie"
name: "X-API-KEY", // name of the header, query parameter or cookie
description: "any description...",
},
},
definitions: {
User: {
name: "Rajendra Prajapat",
email: "hello@gmail.com",
description: "Software Developer",
github: "https://www.github.com/rajpra786",
twitter: "https://twitter.com/msdhoni",
website: "https://www.rajendra.codes/",
avatar: "https://en.wikipedia.org/wiki/File:A._P._J._Abdul_Kalam.jpg",
blogs: [],
},
Blog: {
author: "Author Id",
title: "Blog Title",
content: "<p>Blog Content In HTML</p>",
description: "Few lines about blog",
image: "Poster URL",
readTime: 2,
comments_enabled: true,
comments: "Comment Box Id",
tags: [],
},
Comment: {
author: "Author Id",
message: "Some comment",
},
Comments: {
comments: [
{
$ref: "#/definitions/Comment",
},
],
},
},
};
const outputFile = "./swagger_output.json";
const endpointsFiles = ["./endpoints.js"];
swaggerAutogen(outputFile, endpointsFiles, doc);
// swaggerAutogen(outputFile, endpointsFiles, doc).then(() => {
// require("./index"); // Your project's root file
// });