diff --git a/drf_spectacular/openapi.py b/drf_spectacular/openapi.py index 96730675..2c7fc873 100644 --- a/drf_spectacular/openapi.py +++ b/drf_spectacular/openapi.py @@ -751,7 +751,7 @@ def _get_response_bodies(self, path, method): elif isinstance(response_serializers, dict): # custom handling for overriding default return codes with @extend_schema return { - code: self._get_response_for_code(path, method, serializer) + str(code): self._get_response_for_code(path, method, serializer) for code, serializer in response_serializers.items() } else: diff --git a/tests/test_extend_schema.yml b/tests/test_extend_schema.yml index f36739a4..b8d8ebd5 100644 --- a/tests/test_extend_schema.yml +++ b/tests/test_extend_schema.yml @@ -42,7 +42,7 @@ paths: - {} deprecated: true responses: - 201: + '201': content: application/json: schema: @@ -50,13 +50,13 @@ paths: items: $ref: '#/components/schemas/Beta' description: '' - 200: + '200': content: application/json: schema: $ref: '#/components/schemas/Gamma' description: '' - 500: + '500': content: application/json: schema: @@ -94,7 +94,7 @@ paths: - basicAuth: [] - {} responses: - 201: + '201': description: No response body /doesitall/manual/: post: @@ -166,7 +166,7 @@ paths: - basicAuth: [] - {} responses: - 204: + '204': description: No response body /doesitall/serializer-query/: get: @@ -222,7 +222,7 @@ paths: - basicAuth: [] - {} responses: - 201: + '201': description: No response body components: securitySchemes: