From 6d11663130b8f3221b3a2f824748042f03758489 Mon Sep 17 00:00:00 2001 From: Zyad Sober Date: Mon, 4 Jan 2021 17:34:22 +0000 Subject: [PATCH 1/3] feat: smaller json dump output --- openapi_generator/openapi_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi_generator/openapi_generator.py b/openapi_generator/openapi_generator.py index 26bb2c6..77722fc 100644 --- a/openapi_generator/openapi_generator.py +++ b/openapi_generator/openapi_generator.py @@ -132,7 +132,7 @@ def export(self, filename, extension="json"): """ if extension == "json": with open(filename, 'w') as output_file: - json.dump(self.configs, output_file) + json.dump(self.configs, output_file, separators=(",", ":")) elif extension == "yaml": with open(filename, "w") as output_file: output_file.write(yaml.dump(self.configs, default_flow_style=False)) From 3c03d556ea7ee7a35377fbb06b703a6ada08c1f3 Mon Sep 17 00:00:00 2001 From: Zyad Sober Date: Mon, 4 Jan 2021 17:35:19 +0000 Subject: [PATCH 2/3] fix: Changed https://swapi.co to https://swapi.dev (https://swapi.dev/about) --- openapi_generator/test_generator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openapi_generator/test_generator.py b/openapi_generator/test_generator.py index 695baf5..d8e98c8 100644 --- a/openapi_generator/test_generator.py +++ b/openapi_generator/test_generator.py @@ -8,8 +8,8 @@ class TestOpenapiGenerator(unittest.TestCase): def test_yaml_schema(self): - gen = OpenapiGenerator("Title", "Testing description", "0.0.1", "https://swapi.co") - response = requests.get("https://swapi.co/api/planets/", params={"page": 2}) + gen = OpenapiGenerator("Title", "Testing description", "0.0.1", "https://swapi.dev") + response = requests.get("https://swapi.dev/api/planets/", params={"page": 2}) gen.add_response(response) gen.export("example.yml", extension="yaml") @@ -19,8 +19,8 @@ def test_yaml_schema(self): self.assertEqual(len(list(errors_iterator)), 0) def test_json_schema(self): - gen = OpenapiGenerator("Title", "Testing description", "0.0.1", "https://swapi.co") - response = requests.get("https://swapi.co/api/planets/", params={"page": 2}) + gen = OpenapiGenerator("Title", "Testing description", "0.0.1", "https://swapi.dev") + response = requests.get("https://swapi.dev/api/planets/", params={"page": 2}) gen.add_response(response) gen.export("example.json", extension="json") From 5765cac5f2c3501c663f6443ed9b4d2d48b96803 Mon Sep 17 00:00:00 2001 From: Zyad Sober Date: Mon, 4 Jan 2021 17:36:56 +0000 Subject: [PATCH 3/3] chore: Specified the PyYaml Loader to FullLoader to remove the deprecated warning --- openapi_generator/test_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi_generator/test_generator.py b/openapi_generator/test_generator.py index d8e98c8..a091c9e 100644 --- a/openapi_generator/test_generator.py +++ b/openapi_generator/test_generator.py @@ -14,7 +14,7 @@ def test_yaml_schema(self): gen.export("example.yml", extension="yaml") with open("example.yml") as f: - spec = yaml.load(f) + spec = yaml.load(f, Loader=yaml.FullLoader) errors_iterator = openapi_v3_spec_validator.iter_errors(spec) self.assertEqual(len(list(errors_iterator)), 0)