I'm having trouble using a parent schema that references a child schema via a relative URL.
Here's my parent schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "The parent schema.",
"type": "object",
"properties": {
"parentProp1": { "type": "string"},
"parentProp2": { "$ref": "child.json#"}
}
}
Here's my child schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "The parent schema.",
"type": "object",
"properties": {
"childProp1": { "type": "number" }
}
}
Here's my data:
{
"parentProp1": "one",
"parentProp2": {
"childProp1": 1
}
}
Here's the error I get with ajv-cli
:
$ ajv -s parent.json -d parent-test.json
schema parent.json is invalid
error: can't resolve reference child.json# from id #
I get a similar error (that child.json
can't be resolved) with 3 other validators, which suggests my schema is incorrect.
What am I doing wrong?