How to reference a schema as a subset of another schema


#1

I’m trying to utilize a “base” schema in a secondary schema. The secondary needs all the properties of the BASE with a few additional items as well.

I have not been able to decipher the help documents and various forums to accomplish this.

content.json

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "content",
    "type": "object",
    "properties": {
        "content_id": {"type": "integer"},
        "name": {"type": "string", "minLength": 1},
        "description": {"type": [null, "string"]},
        "rating": {"type": [null, "integer"]},
        "href": {"type": "string"},
    },    
    "required": ["content_id", "name", "description", "rating", "href"]
}

content_admin.json

    {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "content_admin",
    "type": "object",
    "properties": {
       -- everything in CONTENT.JSON
        "content_recurrence": {"type": [null, "integer"]},
        "review_content": {"type": "string"},
    },    
    "required": ["content_recurrence", "review_content"]
}

Thanks for the help.


#2

You might want to add some IDs in your JSON schema. I think that’s probably the problem here. I am not an expert by myself, but I have seen questions around that before on StackOverflow. You might want to checkout JSON schema documentation if you haven’t done that before.