Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 39a9c92

Browse files
Add HTTP 400 Bad Request as a possible generic error response (#1165)
1 parent 590dbb4 commit 39a9c92

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ any parts of the framework not mentioned in the documentation should generally b
1414

1515
* Added support for Python 3.11.
1616
* Added support for Django 4.2.
17+
* Added `400 Bad Request` as a possible error response in the OpenAPI schema.
1718

1819
### Changed
1920

‎example/tests/__snapshots__/test_openapi.ambr‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
"204": {
3939
"description": "[no content](https://jsonapi.org/format/#crud-deleting-responses-204)"
4040
},
41+
"400": {
42+
"content": {
43+
"application/vnd.api+json": {
44+
"schema": {
45+
"$ref": "#/components/schemas/failure"
46+
}
47+
}
48+
},
49+
"description": "bad request"
50+
},
4151
"401": {
4252
"content": {
4353
"application/vnd.api+json": {
@@ -204,6 +214,16 @@
204214
},
205215
"description": "update/authors/{id}"
206216
},
217+
"400": {
218+
"content": {
219+
"application/vnd.api+json": {
220+
"schema": {
221+
"$ref": "#/components/schemas/failure"
222+
}
223+
}
224+
},
225+
"description": "bad request"
226+
},
207227
"401": {
208228
"content": {
209229
"application/vnd.api+json": {
@@ -349,6 +369,16 @@
349369
},
350370
"description": "retrieve/authors/{id}/"
351371
},
372+
"400": {
373+
"content": {
374+
"application/vnd.api+json": {
375+
"schema": {
376+
"$ref": "#/components/schemas/failure"
377+
}
378+
}
379+
},
380+
"description": "bad request"
381+
},
352382
"401": {
353383
"content": {
354384
"application/vnd.api+json": {
@@ -486,6 +516,16 @@
486516
},
487517
"description": "List/authors/"
488518
},
519+
"400": {
520+
"content": {
521+
"application/vnd.api+json": {
522+
"schema": {
523+
"$ref": "#/components/schemas/failure"
524+
}
525+
}
526+
},
527+
"description": "bad request"
528+
},
489529
"401": {
490530
"content": {
491531
"application/vnd.api+json": {
@@ -664,6 +704,16 @@
664704
"204": {
665705
"description": "[Created](https://jsonapi.org/format/#crud-creating-responses-204) with the supplied `id`. No other changes from what was POSTed."
666706
},
707+
"400": {
708+
"content": {
709+
"application/vnd.api+json": {
710+
"schema": {
711+
"$ref": "#/components/schemas/failure"
712+
}
713+
}
714+
},
715+
"description": "bad request"
716+
},
667717
"401": {
668718
"content": {
669719
"application/vnd.api+json": {
@@ -1231,6 +1281,16 @@
12311281
},
12321282
"description": "List/authors/"
12331283
},
1284+
"400": {
1285+
"content": {
1286+
"application/vnd.api+json": {
1287+
"schema": {
1288+
"$ref": "#/components/schemas/failure"
1289+
}
1290+
}
1291+
},
1292+
"description": "bad request"
1293+
},
12341294
"401": {
12351295
"content": {
12361296
"application/vnd.api+json": {

‎rest_framework_json_api/schemas/openapi.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ def _add_generic_failure_responses(self, operation):
779779
Add generic failure response(s) to operation
780780
"""
781781
for code, reason in [
782+
("400", "bad request"),
782783
("401", "not authorized"),
783784
]:
784785
operation["responses"][code] = self._failure_response(reason)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /