Skip to content

Commit 1d89a17

Browse files
authored
Catch case where jsonschema fails on integer status codes (#80)
* Catch case where jsonschema fails on integer status codes
1 parent 62602a0 commit 1d89a17

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/validate_my_definition.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from argparse import ArgumentParser
99
import glob
1010
from almdrlib.client import _YamlOrderedLoader
11-
11+
import json
12+
from openapi_spec_validator import validate_spec
1213
OPENAPI_SCHEMA_URL = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json'
1314

1415

@@ -26,6 +27,11 @@ def validate_definition(definition_file):
2627
except ValidationError as e:
2728
print(f"Validation has failed - schema validation has failed {e}")
2829
exit(1)
30+
except TypeError:
31+
print(f"Validation has failed - json schema trips over integer keys, please "
32+
f"validate your response codes are not integers, check also other keys are not integers"
33+
f"if any of it are, quote it, '200', '400' etc")
34+
exit(1)
2935
print("Validation passed")
3036
else:
3137
print("Input is empty")

0 commit comments

Comments
 (0)