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

Make a dirty hack to read application/json responses of OpenAPI 3.X schemas. #170

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 5 additions & 7 deletions mockintosh/transpilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def path_oas_to_handlebars(self, path: str) -> Tuple[str, Union[int, None]]:
if match is not None:
name = match.group(1).strip()
new_segments.append('{{ %s }}' % name)
last_param_index = i + 1
last_param_index = i
else:
new_segments.append(segment)
return '/'.join(new_segments), last_param_index
Expand Down Expand Up @@ -226,11 +226,9 @@ def _transpile_responses(
'headers': {}
}

if content_type is not None:
response['headers']['Content-Type'] = content_type

if 'schema' in _response:
ref = self._transpile_schema(_response['schema'])
if 'content' in _response:
response['headers']['Content-Type'] = 'application/json' # FIXME: this is a dirty hack for a single case
ref = self._transpile_schema(_response['content']['application/json']['schema'])
response['body'] = self._transpile_body_json_object(ref, last_path_param_index=last_path_param_index)

if 'headers' in _response:
Expand Down Expand Up @@ -330,4 +328,4 @@ def transpile(self, direct: bool = False) -> Union[str, dict]:

file.close()

return target_path
return target_path