From 070077603fc0e231a12eb53121adeb7005d3dcaa Mon Sep 17 00:00:00 2001 From: Lucidiot Date: Thu, 4 Apr 2019 11:06:52 +0200 Subject: [PATCH] Wrap response schemas in a schema object --- rest_framework/schemas/inspectors.py | 5 ++++- tests/schemas/test_openapi.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index 2f178d364..f32e30f71 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -800,6 +800,9 @@ class OpenAPIAutoSchema(ViewInspector): return { '200': { - 'content': {ct: content for ct in self.content_types} + 'content': { + ct: {'schema': content} + for ct in self.content_types + } } } diff --git a/tests/schemas/test_openapi.py b/tests/schemas/test_openapi.py index f33a71361..913185052 100644 --- a/tests/schemas/test_openapi.py +++ b/tests/schemas/test_openapi.py @@ -59,7 +59,7 @@ class TestOperationIntrospection(TestCase): assert operation == { 'operationId': 'ListExamples', 'parameters': [], - 'responses': {'200': {'content': {'application/json': {}}}}, + 'responses': {'200': {'content': {'application/json': {'schema': {}}}}}, } def test_path_with_id_parameter(self): @@ -128,8 +128,8 @@ class TestOperationIntrospection(TestCase): inspector.view = view responses = inspector._get_responses(path, method) - assert responses['200']['content']['application/json']['required'] == ['text'] - assert list(responses['200']['content']['application/json']['properties'].keys()) == ['text'] + assert responses['200']['content']['application/json']['schema']['required'] == ['text'] + assert list(responses['200']['content']['application/json']['schema']['properties'].keys()) == ['text'] @pytest.mark.skipif(uritemplate is None, reason='uritemplate not installed.')