I have two different JSON file structures, one like this:
{
"api": "http://my.api.host",
"modules": [
"core", "module", "another"
]
}
and the other like this:
{
"api": "http://my.api.host",
"modules": "*"
}
The modules
attribute can either be an array or a *
string. How can I represent this in a JSON schema? While using the convenient resource of , I created a structure that validates arrays only:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://jsonschema.net",
"type": "object",
"additionalProperties": true,
"properties": {
"api": {
"id": "http://jsonschema.net/api",
"type": "string",
"minLength": 1
},
"modules": {
"id": "http://jsonschema.net/modules",
"type": "array",
"minItems": 1,
"uniqueItems": false,
"additionalItems": true,
"items": {
"id": "http://jsonschema.net/modules/2",
"type": "string",
"minLength": 1
}
}
},
"required": [
"api",
"modules"
]
}
How can I modify the JSON schema to accommodate both array and wildcard values for the modules
attribute?