openflexure-microscope-server/docs/test_swagger_yaml.py
Richard 1e21ce51fc Some basic validation for OpenAPI
I was getting unhelpful OpenAPI errors, this Python script makes it easier
to figure out where they come from.
2021-07-06 15:18:53 +01:00

15 lines
570 B
Python

import yaml
with open("./build/swagger.yaml", "r") as f:
api = yaml.load(f)
for path, methods in api["paths"].items():
for method, properties in methods.items():
try:
for k in ["responses", "description"]:
current_key = k
_ = properties[k]
for code, r in properties["responses"].items():
current_key = f"responses/{code}/description"
_ = r["description"]
except KeyError as e:
print(f"{method} {path} has a problem: {e} from {current_key}")