Skip to content

Commit 0b6f9eb

Browse files
committed
Add HTTP 429 Too Many Requests as a possible generic error response
1 parent 9d9e47b commit 0b6f9eb

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

example/tests/__snapshots__/test_openapi.ambr

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@
6868
}
6969
},
7070
"description": "[Resource does not exist](https://jsonapi.org/format/#crud-deleting-responses-404)"
71-
}
71+
},
72+
"429": {
73+
"content": {
74+
"application/vnd.api+json": {
75+
"schema": {
76+
"$ref": "#/components/schemas/failure"
77+
}
78+
}
79+
},
80+
"description": "too many requests"
81+
},
7282
},
7383
"tags": [
7484
"authors"
@@ -264,7 +274,17 @@
264274
}
265275
},
266276
"description": "[Conflict]([Conflict](https://jsonapi.org/format/#crud-updating-responses-409)"
267-
}
277+
},
278+
"429": {
279+
"content": {
280+
"application/vnd.api+json": {
281+
"schema": {
282+
"$ref": "#/components/schemas/failure"
283+
}
284+
}
285+
},
286+
"description": "too many requests"
287+
},
268288
},
269289
"tags": [
270290
"authors"
@@ -399,7 +419,17 @@
399419
}
400420
},
401421
"description": "not found"
402-
}
422+
},
423+
"429": {
424+
"content": {
425+
"application/vnd.api+json": {
426+
"schema": {
427+
"$ref": "#/components/schemas/failure"
428+
}
429+
}
430+
},
431+
"description": "too many requests"
432+
},
403433
},
404434
"tags": [
405435
"authors"
@@ -546,7 +576,17 @@
546576
}
547577
},
548578
"description": "not found"
549-
}
579+
},
580+
"429": {
581+
"content": {
582+
"application/vnd.api+json": {
583+
"schema": {
584+
"$ref": "#/components/schemas/failure"
585+
}
586+
}
587+
},
588+
"description": "too many requests"
589+
},
550590
},
551591
"tags": [
552592
"authors"
@@ -754,7 +794,17 @@
754794
}
755795
},
756796
"description": "[Conflict](https://jsonapi.org/format/#crud-creating-responses-409)"
757-
}
797+
},
798+
"429": {
799+
"content": {
800+
"application/vnd.api+json": {
801+
"schema": {
802+
"$ref": "#/components/schemas/failure"
803+
}
804+
}
805+
},
806+
"description": "too many requests"
807+
},
758808
},
759809
"tags": [
760810
"authors"
@@ -1341,7 +1391,17 @@
13411391
}
13421392
},
13431393
"description": "not found"
1344-
}
1394+
},
1395+
"429": {
1396+
"content": {
1397+
"application/vnd.api+json": {
1398+
"schema": {
1399+
"$ref": "#/components/schemas/failure"
1400+
}
1401+
}
1402+
},
1403+
"description": "too many requests"
1404+
},
13451405
},
13461406
"tags": [
13471407
"authors"

rest_framework_json_api/schemas/openapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ def _add_generic_failure_responses(self, operation):
807807
for code, reason in [
808808
("400", "bad request"),
809809
("401", "not authorized"),
810+
("429", "too many requests"),
810811
]:
811812
operation["responses"][code] = self._failure_response(reason)
812813

0 commit comments

Comments
 (0)