Skip to content

Commit f7dc6b5

Browse files
chrisv2carltongibson
authored andcommitted
OpenAPI: Added required description to responses. (#6850)
1 parent 0ebfbfd commit f7dc6b5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

rest_framework/schemas/openapi.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,10 @@ def _get_responses(self, path, method):
490490
'content': {
491491
ct: {'schema': response_schema}
492492
for ct in self.content_types
493-
}
493+
},
494+
# description is a mandatory property,
495+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject
496+
# TODO: put something meaningful into it
497+
'description': ""
494498
}
495499
}

tests/schemas/test_openapi.py

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def test_path_without_parameters(self):
8484
'parameters': [],
8585
'responses': {
8686
'200': {
87+
'description': '',
8788
'content': {
8889
'application/json': {
8990
'schema': {
@@ -190,6 +191,7 @@ class View(generics.GenericAPIView):
190191
responses = inspector._get_responses(path, method)
191192
assert responses['200']['content']['application/json']['schema']['required'] == ['text']
192193
assert list(responses['200']['content']['application/json']['schema']['properties'].keys()) == ['text']
194+
assert 'description' in responses['200']
193195

194196
def test_response_body_nested_serializer(self):
195197
path = '/'
@@ -243,6 +245,7 @@ class View(generics.GenericAPIView):
243245
responses = inspector._get_responses(path, method)
244246
assert responses == {
245247
'200': {
248+
'description': '',
246249
'content': {
247250
'application/json': {
248251
'schema': {
@@ -283,6 +286,7 @@ class View(generics.GenericAPIView):
283286
responses = inspector._get_responses(path, method)
284287
assert responses == {
285288
'200': {
289+
'description': '',
286290
'content': {
287291
'application/json': {
288292
'schema': {

0 commit comments

Comments
 (0)