File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "swagger" : " 2.0" ,
3+ "info" : {
4+ "version" : " 1.0.0" ,
5+ "title" : " My API" ,
6+ "description" : " Documentation automatically generated by the <b>swagger-autogen</b> module."
7+ },
8+ "host" : " localhost:3000" ,
9+ "basePath" : " /" ,
10+ "tags" : [
11+ {
12+ "name" : " User" ,
13+ "description" : " Endpoints"
14+ }
15+ ],
16+ "schemes" : [
17+ " http" ,
18+ " https"
19+ ],
20+ "securityDefinitions" : {
21+ "apiKeyAuth" : {
22+ "type" : " apiKey" ,
23+ "in" : " header" ,
24+ "name" : " X-API-KEY" ,
25+ "description" : " any description..."
26+ }
27+ },
28+ "consumes" : [
29+ " application/json"
30+ ],
31+ "produces" : [
32+ " application/json"
33+ ],
34+ "paths" : {
35+ "/" : {
36+ "get" : {
37+ "description" : " " ,
38+ "parameters" : [],
39+ "responses" : {
40+ "200" : {
41+ "description" : " OK"
42+ }
43+ }
44+ },
45+ "post" : {
46+ "description" : " " ,
47+ "parameters" : [],
48+ "responses" : {
49+ "200" : {
50+ "description" : " OK"
51+ }
52+ }
53+ }
54+ },
55+ "/users/" : {
56+ "get" : {
57+ "description" : " " ,
58+ "parameters" : [],
59+ "responses" : {
60+ "200" : {
61+ "description" : " OK"
62+ }
63+ }
64+ },
65+ "post" : {
66+ "description" : " " ,
67+ "parameters" : [],
68+ "responses" : {
69+ "200" : {
70+ "description" : " OK"
71+ }
72+ }
73+ }
74+ },
75+ "/customers/" : {
76+ "get" : {
77+ "description" : " " ,
78+ "parameters" : [],
79+ "responses" : {
80+ "200" : {
81+ "description" : " OK"
82+ }
83+ }
84+ },
85+ "post" : {
86+ "description" : " " ,
87+ "parameters" : [
88+ {
89+ "name" : " body" ,
90+ "in" : " body" ,
91+ "schema" : {
92+ "type" : " object" ,
93+ "properties" : {
94+ "name" : {
95+ "example" : " any"
96+ },
97+ "age" : {
98+ "example" : " any"
99+ },
100+ "title" : {
101+ "example" : " any"
102+ },
103+ "company" : {
104+ "example" : " any"
105+ }
106+ }
107+ }
108+ }
109+ ],
110+ "responses" : {
111+ "200" : {
112+ "description" : " OK"
113+ }
114+ }
115+ }
116+ },
117+ "/customers/{id}" : {
118+ "get" : {
119+ "description" : " " ,
120+ "parameters" : [
121+ {
122+ "name" : " id" ,
123+ "in" : " path" ,
124+ "required" : true ,
125+ "type" : " string"
126+ }
127+ ],
128+ "responses" : {
129+ "200" : {
130+ "description" : " OK"
131+ }
132+ }
133+ }
134+ },
135+ "/customers/updateName/{id}" : {
136+ "post" : {
137+ "description" : " " ,
138+ "parameters" : [
139+ {
140+ "name" : " id" ,
141+ "in" : " path" ,
142+ "required" : true ,
143+ "type" : " string"
144+ },
145+ {
146+ "name" : " body" ,
147+ "in" : " body" ,
148+ "schema" : {
149+ "type" : " object" ,
150+ "properties" : {
151+ "name" : {
152+ "example" : " any"
153+ }
154+ }
155+ }
156+ }
157+ ],
158+ "responses" : {
159+ "200" : {
160+ "description" : " OK"
161+ }
162+ }
163+ }
164+ },
165+ "/customers/resetAges" : {
166+ "post" : {
167+ "description" : " " ,
168+ "parameters" : [],
169+ "responses" : {
170+ "200" : {
171+ "description" : " OK"
172+ }
173+ }
174+ }
175+ }
176+ }
177+ }
Original file line number Diff line number Diff line change 99 "@types/express" : " ^4.17.15" ,
1010 "@types/jest" : " ^29.2.5" ,
1111 "@types/node" : " ^18.11.18" ,
12+ "@types/swagger-ui-express" : " ^4.1.3" ,
1213 "body-parser" : " ^1.20.1" ,
1314 "dotenv" : " ^16.0.3" ,
1415 "express" : " ^4.18.2" ,
Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ import express from "express";
22import bodyParser from "body-parser" ;
33import userRouter from "./users/views" ;
44import customerRouter from "./customers/views" ;
5+ import swaggerUI from "swagger-ui-express" ;
6+ import spec from "../api-spec.json" ;
57import { dbConnect } from "./database" ;
68
79const app = express ( ) ;
810
911// Middleware to parse json request bodies
1012app . use ( bodyParser . json ( ) ) ;
13+ app . use ( "/api-docs" , swaggerUI . serve , swaggerUI . setup ( spec ) ) ;
1114
1215/**
1316 * Sub-routers for our main router, we should have one sub-router per "entity" in the application
Original file line number Diff line number Diff line change 100100 /* Completeness */
101101 // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
102102 "skipLibCheck" : true /* Skip type checking all .d.ts files. */ ,
103- "emitDecoratorMetadata" : true
103+ "emitDecoratorMetadata" : true ,
104+ "resolveJsonModule" : true ,
104105 }
105106}
Original file line number Diff line number Diff line change 14141414 " @types/qs" " *"
14151415 " @types/range-parser" " *"
14161416
1417- " @types/express@^4.17.15 " :
1417+ " @types/express@* " , "@types/express@ ^4.17.15":
14181418 version "4.17.15"
14191419 resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.15.tgz#9290e983ec8b054b65a5abccb610411953d417ff"
14201420 integrity sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==
14961496 resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
14971497 integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==
14981498
1499+ " @types/swagger-ui-express@^4.1.3 " :
1500+ version "4.1.3"
1501+ resolved "https://registry.yarnpkg.com/@types/swagger-ui-express/-/swagger-ui-express-4.1.3.tgz#7adbbbf5343b45869debef1e9ff39c9ba73e380f"
1502+ integrity sha512-jqCjGU/tGEaqIplPy3WyQg+Nrp6y80DCFnDEAvVKWkJyv0VivSSDCChkppHRHAablvInZe6pijDFMnavtN0vqA==
1503+ dependencies :
1504+ " @types/express" " *"
1505+ " @types/serve-static" " *"
1506+
14991507" @types/webidl-conversions@* " :
15001508 version "7.0.0"
15011509 resolved "https://registry.yarnpkg.com/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz#2b8e60e33906459219aa587e9d1a612ae994cfe7"
You can’t perform that action at this time.
0 commit comments