-
-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using oneOf basing on value attribute #738
Labels
Comments
NicolaSpreafico
changed the title
Using anyOf basing on value attribute
Using oneOf basing on value attribute
May 21, 2019
@NicolaSpreafico I think you are looking for something like this (which assumes you are using draft-07, a.k.a. draft-handrews-json-schema-validation-01): {
"type": "object",
"properties": {
"id": {"type": "integer"},
"values": {
"type": "array",
"items": {
"required": ["type"],
"oneOf": [
{
"if": {"properties": {"type": {"const": "A"}}},
"then": {"properties": {"foo": {"type": "string"}}}
},
{
"if": {"properties": {"type": {"const": "B"}}},
"then": {"properties": {"foo": {"type": "array"}}}
},
{
"if": {"properties": {"type": {"const": "C"}}},
"then": {"properties": {"foo": {"type": "object"}}}
}
]
}
}
}
} |
No further question or response for a couple months, so I'm assuming this was a good enough answer and closing. |
Yes, thank you very much for the reply |
Please see #1082 for related work in this area. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I have a json configured as this example:
Basing on the value of key
type
(which is enum), the schema for propertyvalues
is different.Is there a way to create a conditional-like (like with anyOf) but selecting the proper schema basing on the value of
type
property?The text was updated successfully, but these errors were encountered: