Skip to content

Commit 82ea726

Browse files
Added healthcheck endpoint to Swagger
1 parent 4cd26cb commit 82ea726

File tree

2 files changed

+61
-13
lines changed

2 files changed

+61
-13
lines changed

routes/health.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const router = Router();
77
router.get("/", async function healthGet(req, res, next) {
88
const healthcheck = {
99
uptime: process.uptime(),
10-
message: 'OK',
10+
message: "OK",
1111
timestamp: Date()
1212
};
1313
try {

swagger.yml

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,34 @@ info:
66

77

88
paths:
9+
/health:
10+
get:
11+
summary: Server healthcheck
12+
description: >
13+
If the server is up, returns a 200 response and some basic info about uptime
14+
15+
responses:
16+
'200':
17+
description: Server is alive and healthy
18+
content:
19+
application/json:
20+
schema:
21+
$ref: "#/components/schemas/HealthResponse"
22+
example:
23+
uptime: 1138.00
24+
message: "OK"
25+
timestamp: "Thu Dec 17 2017 19:23:54 GMT+0000"
26+
27+
'503':
28+
description: Server error
29+
content:
30+
application/json:
31+
schema:
32+
$ref: "#/components/schemas/HealthResponse"
33+
example:
34+
uptime: 1138.00
35+
message: "Internal Server Error: Not enough biscuits"
36+
timestamp: "Thu Dec 19 2019 19:23:54 GMT+0000"
937
/bake:
1038
post:
1139
summary: Bakes a recipe
@@ -40,8 +68,7 @@ paths:
4068
content:
4169
application/json:
4270
schema:
43-
type: "string"
44-
value: "Object"
71+
$ref: "#/components/schemas/BakeResponse"
4572
example:
4673
type: "string"
4774
value: "01001110,01111010,01001101,01100111,01001110,01101101,01011001,01100111,01001110,01101101,01010001,01100111,01001110,01101010,01010101,01100111,01001101,01101010,01000001,01100111,01001110,01101010,01101011,01100111,01001110,01101101,01010101,01100111,01001110,01111010,01000001,01100111,01001110,01111010,01010101,01100111,01001110,01111010,01010001,00111101"
@@ -71,9 +98,7 @@ paths:
7198
content:
7299
application/json:
73100
schema:
74-
type: "string"
75-
value:
76-
$ref: "#/components/schemas/MagicResponse"
101+
$ref: "#/components/schemas/MagicResponse"
77102
example:
78103
type: 6
79104
value:
@@ -127,11 +152,12 @@ components:
127152
properties:
128153
op:
129154
type: string
130-
required: true
131155
args:
132156
oneOf:
133157
- $ref: "#/components/schemas/ArgArray"
134158
- $ref: "#/components/schemas/ArgObject"
159+
required:
160+
- op
135161

136162
OperationArray:
137163
type: array
@@ -141,7 +167,7 @@ components:
141167
ArgArray:
142168
type: array
143169
items:
144-
type: {}
170+
type: object
145171
example:
146172
- 16
147173
- true
@@ -154,6 +180,16 @@ components:
154180
upperCaseHex: true
155181
includeFinalLength: false
156182

183+
BakeResponse:
184+
type: object
185+
properties:
186+
type:
187+
type: string
188+
value:
189+
oneOf:
190+
- type: string
191+
- type: number
192+
157193
MagicInput:
158194
type: object
159195
properties:
@@ -166,7 +202,7 @@ components:
166202
type: object
167203
properties:
168204
type:
169-
type: int
205+
type: integer
170206
value:
171207
type: array
172208
items:
@@ -177,16 +213,28 @@ components:
177213
recipe:
178214
type: array
179215
items:
180-
type: Object
216+
type: object
181217
data:
182218
type: string
183219
languageScores:
184220
type: array
185221
items:
186-
type: Object
222+
type: object
187223
matchingOps:
188224
type: array
189225
items:
190-
type: Object
191-
useful: bool
226+
type: object
227+
useful:
228+
type: boolean
229+
230+
HealthResponse:
231+
type: object
232+
properties:
233+
uptime:
234+
type: number
235+
message:
236+
type: string
237+
timestamp:
238+
type: string
239+
192240

0 commit comments

Comments
 (0)