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)) diff --git a/openapi_generator/test_generator.py b/openapi_generator/test_generator.py index 695baf5..a091c9e 100644 --- a/openapi_generator/test_generator.py +++ b/openapi_generator/test_generator.py @@ -8,19 +8,19 @@ 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") 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) 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")