From 37989a3c11e50d7205a6d8143eddca302373f4a7 Mon Sep 17 00:00:00 2001 From: Yuri Apollov Date: Thu, 31 Mar 2022 22:01:02 +0300 Subject: [PATCH 1/2] Make a dirty hack to read application/json responses of OpenAPI 3.X schemas. --- mockintosh/transpilers.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mockintosh/transpilers.py b/mockintosh/transpilers.py index 04744ce58..34247c37d 100644 --- a/mockintosh/transpilers.py +++ b/mockintosh/transpilers.py @@ -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: @@ -330,4 +328,4 @@ def transpile(self, direct: bool = False) -> Union[str, dict]: file.close() - return target_path + return target_path \ No newline at end of file From 9633bf346a81f77f7da30e9a119010b2c262347e Mon Sep 17 00:00:00 2001 From: Yuri Apollov Date: Wed, 6 Apr 2022 14:13:25 +0300 Subject: [PATCH 2/2] Fix templates paths with variables inside didn't substitute variables. --- mockintosh/transpilers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mockintosh/transpilers.py b/mockintosh/transpilers.py index 34247c37d..6c5341db9 100644 --- a/mockintosh/transpilers.py +++ b/mockintosh/transpilers.py @@ -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