Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11855 - Swagger not working correctly for pay-api / auth-api #1940

Merged
merged 4 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion auth-api/src/auth_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def add_version(response):
response.headers['API'] = f'auth_api/{version}'

def camelize_json(response):
if response.headers['Content-Type'] == 'application/json':
if (response.headers['Content-Type'] == 'application/json' and
'swagger.json' not in request.base_url):
response.set_data(json.dumps(camelize(json.loads(response.get_data()))))

register_shellcontext(app)
Expand Down
7 changes: 4 additions & 3 deletions auth-api/src/auth_api/resources/documents_affidavit.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ def get():
try:
doc = DocumentService.fetch_latest_document(DocumentType.AFFIDAVIT.value)
if doc is None:
return {'message': 'The requested document could not be found.'}, \
response, status = {'message': 'The requested document could not be found.'}, \
http_status.HTTP_404_NOT_FOUND
if doc.as_dict().get('content_type', None) == ContentType.PDF.value: # pdfs has to be served as attachment
elif doc.as_dict().get('content_type', None) == ContentType.PDF.value: # pdf has to be served as attachment
return send_from_directory('static', filename=doc.as_dict()['content'], as_attachment=True)

else:
response, status = doc.as_dict(), http_status.HTTP_200_OK
except BusinessException as exception:
response, status = {'code': exception.code, 'message': exception.message}, exception.status_code
return response, status