Skip to content
Open
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
2 changes: 1 addition & 1 deletion openapi_generator/openapi_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions openapi_generator/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down