Skip to content

Commit

Permalink
Added HTTP 429 Too Many Requests as a possible generic error response (
Browse files Browse the repository at this point in the history
…#1226)

* Add HTTP 429 Too Many Requests as a possible generic error response

* Update CHANGELOG.md

---------

Co-authored-by: Oliver Sauder <[email protected]>
  • Loading branch information
js-nh and sliverc authored May 29, 2024
1 parent 9d9e47b commit 21493c1
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Note that in line with [Django REST framework policy](https://www.django-rest-framework.org/topics/release-notes/),
any parts of the framework not mentioned in the documentation should generally be considered private API, and may be subject to change.

## [Unreleased]

### Added

* Added `429 Too Many Requests` as a possible error response in the OpenAPI schema.

## [7.0.0] - 2024-05-02

### Added
Expand Down
60 changes: 60 additions & 0 deletions example/tests/__snapshots__/test_openapi.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
}
},
"description": "[Resource does not exist](https://jsonapi.org/format/#crud-deleting-responses-404)"
},
"429": {
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/failure"
}
}
},
"description": "too many requests"
}
},
"tags": [
Expand Down Expand Up @@ -264,6 +274,16 @@
}
},
"description": "[Conflict]([Conflict](https://jsonapi.org/format/#crud-updating-responses-409)"
},
"429": {
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/failure"
}
}
},
"description": "too many requests"
}
},
"tags": [
Expand Down Expand Up @@ -399,6 +419,16 @@
}
},
"description": "not found"
},
"429": {
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/failure"
}
}
},
"description": "too many requests"
}
},
"tags": [
Expand Down Expand Up @@ -546,6 +576,16 @@
}
},
"description": "not found"
},
"429": {
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/failure"
}
}
},
"description": "too many requests"
}
},
"tags": [
Expand Down Expand Up @@ -754,6 +794,16 @@
}
},
"description": "[Conflict](https://jsonapi.org/format/#crud-creating-responses-409)"
},
"429": {
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/failure"
}
}
},
"description": "too many requests"
}
},
"tags": [
Expand Down Expand Up @@ -1341,6 +1391,16 @@
}
},
"description": "not found"
},
"429": {
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/failure"
}
}
},
"description": "too many requests"
}
},
"tags": [
Expand Down
1 change: 1 addition & 0 deletions rest_framework_json_api/schemas/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ def _add_generic_failure_responses(self, operation):
for code, reason in [
("400", "bad request"),
("401", "not authorized"),
("429", "too many requests"),
]:
operation["responses"][code] = self._failure_response(reason)

Expand Down

0 comments on commit 21493c1

Please sign in to comment.