Skip to content

Commit 55279f1

Browse files
committed
fix #6833
1 parent 659375f commit 55279f1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

rest_framework/schemas/openapi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,10 @@ def _get_responses(self, path, method):
483483
'content': {
484484
ct: {'schema': content}
485485
for ct in self.content_types
486-
}
486+
},
487+
# description is a mandatory property,
488+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject
489+
# TODO: put something meaningful into it
490+
'description': ""
487491
}
488492
}

tests/schemas/test_openapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_path_without_parameters(self):
7272
assert operation == {
7373
'operationId': 'ListExamples',
7474
'parameters': [],
75-
'responses': {'200': {'content': {'application/json': {'schema': {}}}}},
75+
'responses': {'200': {'content': {'application/json': {'schema': {}}}, 'description': ''}},
7676
}
7777

7878
def test_path_with_id_parameter(self):
@@ -143,6 +143,7 @@ class View(generics.GenericAPIView):
143143
responses = inspector._get_responses(path, method)
144144
assert responses['200']['content']['application/json']['schema']['required'] == ['text']
145145
assert list(responses['200']['content']['application/json']['schema']['properties'].keys()) == ['text']
146+
assert 'description' in responses['200']
146147

147148
def test_response_body_nested_serializer(self):
148149
path = '/'

0 commit comments

Comments
 (0)