mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
only set schema response content if there is one
This commit is contained in:
parent
00cd4ef864
commit
545f7a5ed8
|
@ -687,18 +687,20 @@ class AutoSchema(ViewInspector):
|
||||||
else:
|
else:
|
||||||
response_schema = item_schema
|
response_schema = item_schema
|
||||||
status_code = '201' if method == 'POST' else '200'
|
status_code = '201' if method == 'POST' else '200'
|
||||||
return {
|
response = {
|
||||||
status_code: {
|
status_code: {
|
||||||
'content': {
|
|
||||||
ct: {'schema': response_schema}
|
|
||||||
for ct in self.response_media_types
|
|
||||||
},
|
|
||||||
# description is a mandatory property,
|
# description is a mandatory property,
|
||||||
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject
|
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject
|
||||||
# TODO: put something meaningful into it
|
# TODO: put something meaningful into it
|
||||||
'description': ""
|
'description': ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if self.response_media_types:
|
||||||
|
response[status_code]['content'] = {
|
||||||
|
ct: {'schema': response_schema}
|
||||||
|
for ct in self.response_media_types
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
|
||||||
def get_tags(self, path, method):
|
def get_tags(self, path, method):
|
||||||
# If user have specified tags, use them.
|
# If user have specified tags, use them.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user