By the below example question will get more clear:
data = {"type": "object", "properties": {"product": {"type": ["boolean","string"]}}}
It includes both boolean
and string
types. It works, but I want to limit the string part to a list of enums
:
["off", "on", "semi-on"]
When type
is not a list
it works, but when I make it as a list then I cannot provide the enum
for the string
type.
The below example without boolean
works too:
data = {"type": "object", "properties": {"product": {"type": "string", "enum": ["off", "on", "semi-on"]}}}
Should split the schema, or is there another way for this?
EDIT-1: The real schema is as below:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"is_trusted": {"type": "boolean"},
"is_active": {"type": "boolean"},
"addresses": {"type": "array"},
"attachments": {
"type": "object",
"properties": {
"send_web_push": {"type": "boolean"},
"receive_web_push": {"type": "boolean"}
},
"required": ["send_web_push", "receive_web_push"],
"additionalProperties": false
}
},
"required": ["is_trusted", "is_active", "addresses"],
"additionalProperties": false
}