diff --git a/CHANGELOG.md b/CHANGELOG.md index a5f86d1d..05ebecd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ any parts of the framework not mentioned in the documentation should generally b * Added support for Python 3.11. * Added support for Django 4.2. +* Added `400 Bad Request` as a possible error response in the OpenAPI schema. ### Changed diff --git a/example/tests/__snapshots__/test_openapi.ambr b/example/tests/__snapshots__/test_openapi.ambr index 93b8f7fb..28cb78f0 100644 --- a/example/tests/__snapshots__/test_openapi.ambr +++ b/example/tests/__snapshots__/test_openapi.ambr @@ -38,6 +38,16 @@ "204": { "description": "[no content](https://jsonapi.org/format/#crud-deleting-responses-204)" }, + "400": { + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/failure" + } + } + }, + "description": "bad request" + }, "401": { "content": { "application/vnd.api+json": { @@ -204,6 +214,16 @@ }, "description": "update/authors/{id}" }, + "400": { + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/failure" + } + } + }, + "description": "bad request" + }, "401": { "content": { "application/vnd.api+json": { @@ -349,6 +369,16 @@ }, "description": "retrieve/authors/{id}/" }, + "400": { + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/failure" + } + } + }, + "description": "bad request" + }, "401": { "content": { "application/vnd.api+json": { @@ -486,6 +516,16 @@ }, "description": "List/authors/" }, + "400": { + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/failure" + } + } + }, + "description": "bad request" + }, "401": { "content": { "application/vnd.api+json": { @@ -664,6 +704,16 @@ "204": { "description": "[Created](https://jsonapi.org/format/#crud-creating-responses-204) with the supplied `id`. No other changes from what was POSTed." }, + "400": { + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/failure" + } + } + }, + "description": "bad request" + }, "401": { "content": { "application/vnd.api+json": { @@ -1231,6 +1281,16 @@ }, "description": "List/authors/" }, + "400": { + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/failure" + } + } + }, + "description": "bad request" + }, "401": { "content": { "application/vnd.api+json": { diff --git a/rest_framework_json_api/schemas/openapi.py b/rest_framework_json_api/schemas/openapi.py index a0d2be0d..9c1dd620 100644 --- a/rest_framework_json_api/schemas/openapi.py +++ b/rest_framework_json_api/schemas/openapi.py @@ -779,6 +779,7 @@ def _add_generic_failure_responses(self, operation): Add generic failure response(s) to operation """ for code, reason in [ + ("400", "bad request"), ("401", "not authorized"), ]: operation["responses"][code] = self._failure_response(reason)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: