'Reference Another Schema in Web Validator
I'm trying to learn JSON schema and choose the web validator to validate some examples. It works fine except when I try to reference another schema. The schemas are saved in my machine and I don't know how to make it works, or even if this kind of operation works in web validator.
When I try to use the validator with reference, I get the following error: Error parsing schema Message: Error when resolving schema reference 'file:///D:/schema/address.schema.json'. Path 'properties.shipping_address', line 12, position 25.
[![error image][1]][1] [1]: https://i.stack.imgur.com/6z2pY.png
Any help will be appreciated!
The schemas and JSON used are show below:
{
"$id": "D:/schema/customer.schema.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"shipping_address": {
"$ref": "D:/schema/address.schema.json"
},
"billing_address": {
"$ref": "D:/schema/address.schema.json"
}
},
"required": [
"first_name",
"last_name",
"shipping_address",
"billing_address"
]
}
---
{
"$id": "D:/schema/address.schema.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"properties": {
"street_address": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
}
},
"required": [
"street_address",
"city",
"state"
]
}
--- JSON
{
"first_name": "first",
"last_name": "last",
"shipping_address": {
"street_address": "street",
"city": "city",
"state": "ST"
},
"billing_address": {
"street_address": "street",
"city": "city",
"state": "ST"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
