-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Description
Problem
When the $id
is set to use a file protocol like in this case file:///mnt/server/userdata/source/json-schemas/schema/customer.schema.json
an error is reported when other schema files are referenced for definitions.
As a comparison the validator from the Linux package
python3-jsonschema
only allowsfile://
protocol for local files which is the most logical in my opinion.
(The problem there is that it does not handle relative file paths.)
Directory Structure & Command
Files
<project-dir>
├── json
│ ├── test.customer.json
└── schema
├── address.schema.json
├── customer.schema.json
└── defs.schema.json
Command
Both commands are executed when the current directory is the project root.
Python
jsonschema -i json/test.customer.json schema/customer.schema.json
C++ json-schema-validator
json-schema-validate schema/customer.schema.json < json/test.customer.json
Main Schema File
The file below references other files.
Those files can be found at this location.
{
"$id": "file:///mnt/server/userdata/source/json-schemas/schema/customer.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "object",
"additionalProperties": false,
"properties": {
"first": {
"$ref": "defs.schema.json#/definitions/firstName"
},
"middle": {
"$ref": "defs.schema.json#/definitions/middleName"
},
"last": {
"$ref": "defs.schema.json#/definitions/lastName"
}
},
"required": [
"first",
"middle",
"last"
]
},
"shipping_address": {
"$ref": "address.schema.json"
},
"billing_address": {
"$ref": "address.schema.json"
},
"parcel_size": {
"type": "object",
"additionalProperties": false,
"properties": {
"height": {
"$ref": "defs.schema.json#/definitions/parcelSizeHeight"
},
"width": {
"$ref": "defs.schema.json#/definitions/parcelSizeWidth"
},
"depth": {
"$ref": "defs.schema.json#/definitions/parcelSizeDepth"
}
}
}
},
"required": [
"name",
"shipping_address",
"billing_address",
"parcel_size"
]
}
Error Log
setting root schema failed
could not open file:///mnt/server/userdata/source/json-schemas/schema/address.schema.json tried with .//mnt/server/userdata/source/json-schemas/schema/address.schema.json
ERROR: '"/billing_address"' - '{"city":"'s-Gravenhage","postal_code":"2514GL","state":"Zuid-Holland","street_address":"Noordeinde 68"}': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/address.schema.json #
ERROR: '"/name/first"' - '"Prins"': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/defs.schema.json # /definitions/firstName
ERROR: '"/name/last"' - '"Oranje"': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/defs.schema.json # /definitions/lastName
ERROR: '"/name/middle"' - '"van"': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/defs.schema.json # /definitions/middleName
ERROR: '"/parcel_size/depth"' - '30': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/defs.schema.json # /definitions/parcelSizeDepth
ERROR: '"/parcel_size/height"' - '200': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/defs.schema.json # /definitions/parcelSizeHeight
ERROR: '"/parcel_size/width"' - '80': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/defs.schema.json # /definitions/parcelSizeWidth
ERROR: '"/shipping_address"' - '{"city":"'s-Gravenhage","postal_code":"2513BJ","state":"Zuid-Hoilland","street_address":"Molenstraat 27"}': unresolved or freed schema-reference file:///mnt/server/userdata/source/json-schemas/schema/address.schema.json #
schema validation failed
Metadata
Metadata
Assignees
Labels
No labels