Some basic validation for OpenAPI

I was getting unhelpful OpenAPI errors, this Python script makes it easier
to figure out where they come from.
This commit is contained in:
Richard 2021-07-06 15:18:53 +01:00
parent 8157fa6d58
commit 1e21ce51fc

15
docs/test_swagger_yaml.py Normal file
View file

@ -0,0 +1,15 @@
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}")