only set schema response content if there is one

This commit is contained in:
Fábio Domingues 2021-10-29 14:24:19 +01:00 committed by GitHub
parent 00cd4ef864
commit 545f7a5ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.