Skip to content

Commit d207843

Browse files
alade-devTeslim Ibisomi
andauthored
docs: add reusable OpenAPI response definitions for 400, 401, 429 error formats (#672)
Co-authored-by: Teslim Ibisomi <johndoe@example.com>
1 parent ed33c84 commit d207843

1 file changed

Lines changed: 47 additions & 30 deletions

File tree

backend/docs/openapi.yaml

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,33 @@ components:
3232
bearerFormat: JWT
3333
description: JWT obtained from POST /api/auth/verify
3434

35+
responses:
36+
BadRequest:
37+
description: Bad Request - Invalid input, missing required fields, or malformed data
38+
content:
39+
application/json:
40+
schema:
41+
$ref: '#/components/schemas/ErrorResponse'
42+
example:
43+
error: Invalid signature format (must be hex or base64)
44+
45+
Unauthorized:
46+
description: Unauthorized - Missing or invalid JWT / authentication credentials
47+
content:
48+
application/json:
49+
schema:
50+
$ref: '#/components/schemas/ErrorResponse'
51+
example:
52+
error: Missing authorization header
53+
54+
TooManyRequests:
55+
description: Too Many Requests - Rate limit exceeded; retry after a short delay
56+
content:
57+
text/plain:
58+
schema:
59+
type: string
60+
example: Too many requests, please try again later.
61+
3562
schemas:
3663
ErrorResponse:
3764
type: object
@@ -538,6 +565,8 @@ paths:
538565
$ref: '#/components/schemas/ChallengeResponse'
539566
example:
540567
challenge: "3fa85f64-5717-4562-b3fc-2c963f66afa6"
568+
'429':
569+
$ref: '#/components/responses/TooManyRequests'
541570

542571
/api/auth/verify:
543572
post:
@@ -574,6 +603,8 @@ paths:
574603
$ref: '#/components/schemas/ErrorResponse'
575604
example:
576605
error: Signature verification failed
606+
'429':
607+
$ref: '#/components/responses/TooManyRequests'
577608
'500':
578609
description: Internal server error
579610
content:
@@ -606,6 +637,8 @@ paths:
606637
$ref: '#/components/schemas/ErrorResponse'
607638
example:
608639
error: Missing authorization header
640+
'429':
641+
$ref: '#/components/responses/TooManyRequests'
609642
'500':
610643
description: Internal server error
611644
content:
@@ -641,6 +674,8 @@ paths:
641674
application/json:
642675
schema:
643676
$ref: '#/components/schemas/ErrorResponse'
677+
'429':
678+
$ref: '#/components/responses/TooManyRequests'
644679
'500':
645680
description: Internal server error
646681
content:
@@ -678,6 +713,8 @@ paths:
678713
application/json:
679714
schema:
680715
$ref: '#/components/schemas/ErrorResponse'
716+
'429':
717+
$ref: '#/components/responses/TooManyRequests'
681718
'500':
682719
description: Internal server error
683720
content:
@@ -708,6 +745,8 @@ paths:
708745
application/json:
709746
schema:
710747
$ref: '#/components/schemas/ErrorResponse'
748+
'429':
749+
$ref: '#/components/responses/TooManyRequests'
711750
'500':
712751
description: Internal server error
713752
content:
@@ -755,6 +794,8 @@ paths:
755794
application/json:
756795
schema:
757796
$ref: '#/components/schemas/ErrorResponse'
797+
'429':
798+
$ref: '#/components/responses/TooManyRequests'
758799
'500':
759800
description: Internal server error
760801
content:
@@ -810,11 +851,7 @@ paths:
810851
items:
811852
$ref: '#/components/schemas/FeedItem'
812853
'401':
813-
description: Missing or invalid JWT
814-
content:
815-
application/json:
816-
schema:
817-
$ref: '#/components/schemas/ErrorResponse'
854+
$ref: '#/components/responses/Unauthorized'
818855
'500':
819856
description: Internal server error
820857
content:
@@ -840,11 +877,7 @@ paths:
840877
items:
841878
$ref: '#/components/schemas/FeedItem'
842879
'401':
843-
description: Missing or invalid JWT
844-
content:
845-
application/json:
846-
schema:
847-
$ref: '#/components/schemas/ErrorResponse'
880+
$ref: '#/components/responses/Unauthorized'
848881
'500':
849882
description: Internal server error
850883
content:
@@ -1177,11 +1210,7 @@ paths:
11771210
offset: 0
11781211
total: 1
11791212
'401':
1180-
description: Missing or invalid JWT
1181-
content:
1182-
application/json:
1183-
schema:
1184-
$ref: '#/components/schemas/ErrorResponse'
1213+
$ref: '#/components/responses/Unauthorized'
11851214
'500':
11861215
description: Internal server error
11871216
content:
@@ -1229,11 +1258,7 @@ paths:
12291258
error: Insufficient available balance
12301259
available: 1000000
12311260
'401':
1232-
description: Missing or invalid JWT
1233-
content:
1234-
application/json:
1235-
schema:
1236-
$ref: '#/components/schemas/ErrorResponse'
1261+
$ref: '#/components/responses/Unauthorized'
12371262
'500':
12381263
description: Internal server error
12391264
content:
@@ -1281,11 +1306,7 @@ paths:
12811306
error: Insufficient earning balance
12821307
earning: 1000000
12831308
'401':
1284-
description: Missing or invalid JWT
1285-
content:
1286-
application/json:
1287-
schema:
1288-
$ref: '#/components/schemas/ErrorResponse'
1309+
$ref: '#/components/responses/Unauthorized'
12891310
'500':
12901311
description: Internal server error
12911312
content:
@@ -1320,11 +1341,7 @@ paths:
13201341
auto_earn_enabled: true
13211342
message: "Auto-earn enabled. Idle stablecoins will be swept into the yield vault."
13221343
'401':
1323-
description: Missing or invalid JWT
1324-
content:
1325-
application/json:
1326-
schema:
1327-
$ref: '#/components/schemas/ErrorResponse'
1344+
$ref: '#/components/responses/Unauthorized'
13281345
'500':
13291346
description: Internal server error
13301347
content:

0 commit comments

Comments
 (0)