Skip to content

Commit

Permalink
#173: Order OpenAPI YAML request types alphabetically
Browse files Browse the repository at this point in the history
- Things like get, patch, post, delete etc. weren't alphabetically ordered as changing the order of the YAML file on startup
  • Loading branch information
MRichards99 committed Oct 15, 2020
1 parent adcb7a6 commit 88c623a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def handle_error(e):
)
spec.path(resource=InstrumentsFacilityCyclesInvestigationsCount, api=api)

# Reorder paths (e.g. get, patch, post) so openapi.yaml only changes when there's a
# change to the Swagger docs, rather than changing on each startup
for entity_data in spec._paths.values():
for endpoint_name in sorted(entity_data.keys()):
entity_data.move_to_end(endpoint_name)

openapi_spec_path = Path(__file__).parent / "swagger/openapi.yaml"
with open(openapi_spec_path, "w") as f:
f.write(spec.to_yaml())
Expand Down

0 comments on commit 88c623a

Please sign in to comment.