I want the common parts of json schema to be captured in a file and then reference this file from the main schema file. So basically instead of 1 big json schema file, multiple files which reference each other. Am using json-schema-validator lib to validate.
E.g.:
$ ls schemas/
response_schema.json results_schema.json
$ cat schemas/response_schema.json
{
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
"required": [ "results" ],
"properties": {
"results": "####Reference results_schema.json file here somehow####"
}
}
$ cat schemas/results_schema.json
{
"$schema": "http://json-schema.org/draft-04/schema",
"type": "array",
"items": {
"type": "object",
"required": ["type", "name"],
"properties": {
"name": { "type": "string" },
"dateOfBirth": { "type": "string" }
}
}
}
Following solution worked for me:
"results": {
"$ref": "file:src/test/resources/schemas/results.json"
}
The above solution satisfies my requirements:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With