Skip to content

Commit

Permalink
Merge pull request #174 from ral-facilities/feature/make-swagger-yaml…
Browse files Browse the repository at this point in the history
…-stay-same-on-startup

Make swagger YAML stay the same on startup
  • Loading branch information
MRichards99 authored Nov 26, 2020
2 parents adcb7a6 + 537cafc commit 58f995b
Show file tree
Hide file tree
Showing 2 changed files with 2,078 additions and 2,072 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
Loading

0 comments on commit 58f995b

Please sign in to comment.