Skip to content

Commit

Permalink
OpenAPI: Added required description to responses. (#6850)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisv2 authored and carltongibson committed Aug 7, 2019
1 parent 0ebfbfd commit f7dc6b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rest_framework/schemas/openapi.py
Expand Up @@ -490,6 +490,10 @@ def _get_responses(self, path, method):
'content': {
ct: {'schema': response_schema}
for ct in self.content_types
}
},
# description is a mandatory property,
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject
# TODO: put something meaningful into it
'description': ""
}
}
4 changes: 4 additions & 0 deletions tests/schemas/test_openapi.py
Expand Up @@ -84,6 +84,7 @@ def test_path_without_parameters(self):
'parameters': [],
'responses': {
'200': {
'description': '',
'content': {
'application/json': {
'schema': {
Expand Down Expand Up @@ -190,6 +191,7 @@ class View(generics.GenericAPIView):
responses = inspector._get_responses(path, method)
assert responses['200']['content']['application/json']['schema']['required'] == ['text']
assert list(responses['200']['content']['application/json']['schema']['properties'].keys()) == ['text']
assert 'description' in responses['200']

def test_response_body_nested_serializer(self):
path = '/'
Expand Down Expand Up @@ -243,6 +245,7 @@ class View(generics.GenericAPIView):
responses = inspector._get_responses(path, method)
assert responses == {
'200': {
'description': '',
'content': {
'application/json': {
'schema': {
Expand Down Expand Up @@ -283,6 +286,7 @@ class View(generics.GenericAPIView):
responses = inspector._get_responses(path, method)
assert responses == {
'200': {
'description': '',
'content': {
'application/json': {
'schema': {
Expand Down

0 comments on commit f7dc6b5

Please sign in to comment.