Skip to content

Commit

Permalink
v0.0.19
Browse files Browse the repository at this point in the history
feat: openapi spec v3 responses
  • Loading branch information
wvolkov authored May 26, 2021
2 parents 8f9194e + f7fe63e commit f3ee69a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_packages(package):
'apispec<4',
'python-multipart'
],
version='0.0.18',
version='0.0.19',
url='https://github.com/slv0/start_resty',
license='BSD',
description='The web framework',
Expand Down
2 changes: 1 addition & 1 deletion star_resty/apidocs/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup_operation(endpoint: Method, version=2):
'summary': options.summary,
'produces': [endpoint.serializer.media_type],
'parameters': resolve_parameters(endpoint),
'responses': resolve_responses(endpoint),
'responses': resolve_responses(endpoint, version),
}

if options.security is not None:
Expand Down
13 changes: 11 additions & 2 deletions star_resty/apidocs/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@
__all__ = ('resolve_responses',)


def resolve_responses(endpoint: Method):
def resolve_responses(endpoint: Method, version: int):
responses = {}
if endpoint.response_schema:
responses[str(endpoint.status_code)] = {
if version == 3:
responses[str(endpoint.status_code)] = {
'content': {
endpoint.serializer.media_type: {
'schema': endpoint.response_schema
}
}
}
else:
responses[str(endpoint.status_code)] = {
'schema': endpoint.response_schema
}

Expand Down

0 comments on commit f3ee69a

Please sign in to comment.