I'm trying to validate my JSON API using node.js + json-schema.js from commonjs-utils. Just single validation was easy but could not find right way how to manage multiple schema files to enable referencing each other.
Suppose that I got two Models & two APIs.
// book
{
"type": "object",
"properties": {
"title": { "type": "string" },
"author": { "type": "string" }
}
}
// author
{
"type": "object",
"properties": {
"first_name": { "type": "string" },
"last_name": { "type": "string" }
}
}
// authors API
{
"type": "array",
"items": { "$ref": "author" }
}
// books API: list of books written by same author
{
"type": "object",
"properties": {
"author": { "$ref": "author" }
"books": { "type": "array", "items": { "$ref": "book" } }
}
}
Each schema should be divided in separate file and be online? Or Can I combine into single schema file like below? If it is possible, how can I reference local schema?
// single schema file {
"book": { ... },
"author": { ... },
"authors": { ... },
"books": { ... } }
question from:https://stackoverflow.com/questions/8179137/how-to-manage-multiple-json-schema-files