Closed
Description
Hey there,
I have been trying to write a YAML schema referencing another YAML schema [1].
This results in:
Failure resolving $ref within schema
RefResolutionError: Expecting value: line 1 column 1 (char 0)
in "/usr/local/lib/python3.8/dist-packages/check_jsonschema/checker.py", line 73
>>> errors = self._build_error_map()
caused by
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
in "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 816
>>> document = self.resolve_remote(url)
caused by
StopIteration: 0
in "/usr/lib/python3.8/json/decoder.py", line 353
>>> obj, end = self.scan_once(s, idx)
caused by
KeyError: 'file:///path/to/B.schema.yml'
in "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 813
>>> document = self.store[url]
It does make sense, as resolving the reference schema is handled by jsonschema, which has no support for YAML − took me a while to get there though :)
Hence I’m not sure whether much can be done in check-jsonschema (perhaps some documentation clarification and/or error message hint)
[1] Something along the lines of the following − exact syntax might be still be off as I’m still figuring things out ^_^
$schema: "https://json-schema.org/draft/2020-12/schema"
description: A schema
type: object
$ref: "B.schema.yml#properties"
required:
- foo
$schema: "https://json-schema.org/draft/2020-12/schema"
description: B
type: object
properties:
foo:
type: string
bar:
type: integer