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:
parent
8157fa6d58
commit
1e21ce51fc
1 changed files with 15 additions and 0 deletions
15
docs/test_swagger_yaml.py
Normal file
15
docs/test_swagger_yaml.py
Normal 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}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue