Bypass jsonschema references resolver
jsonschema's resolver doesn't work with local files on Windows. resolve_references only works with the local files (on Windows as well) but that's exactly what's needed for the case (as long as we don't have remote references, that is). Signed-off-by: Alexey Rusakov <Alexey.Rusakov@pm.me>
This commit is contained in:
parent
d17ec7f184
commit
c6bfac41c5
1 changed files with 2 additions and 4 deletions
|
@ -44,16 +44,14 @@ except ImportError as e:
|
|||
|
||||
|
||||
def check_schema(filepath, example, schema):
|
||||
# Setting the 'id' tells jsonschema where the file is so that it
|
||||
# can correctly resolve relative $ref references in the schema
|
||||
schema['id'] = "file://" + os.path.abspath(filepath)
|
||||
example = resolve_references(filepath, example)
|
||||
schema = resolve_references(filepath, schema)
|
||||
resolver = jsonschema.RefResolver(filepath, schema, handlers={"file": load_file})
|
||||
jsonschema.validate(example, schema, resolver=resolver)
|
||||
|
||||
|
||||
def check_parameter(filepath, request, parameter):
|
||||
schema = parameter.get("schema")
|
||||
schema = parameter.get("schema", {})
|
||||
example = schema.get('example')
|
||||
|
||||
if example and schema:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue