From 61b2c9558587f50e4c371a71a7a9545b0fd36dea Mon Sep 17 00:00:00 2001 From: "T. Franzel" <13507857+tfranzel@users.noreply.github.com> Date: Mon, 30 Mar 2020 17:52:54 +0200 Subject: [PATCH] bugfix: response codes must be string. closes #17 --- drf_spectacular/openapi.py | 2 +- tests/test_extend_schema.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) 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: