Nested anyOf not working as expected
See original GitHub issueUsing the playground, the schema below works as expected;
Working schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"options1": {
"type": "string",
"enum": [
"a",
"b"
]
},
"options2": {
"type": "string",
"enum": [
"c",
"d"
]
}
},
"type": "object",
"properties": {
"only1": {
"title": "Only 1",
"$ref": "#/definitions/options1"
},
"only2": {
"title": "Only 2",
"$ref": "#/definitions/options2"
},
"both": {
"title": "1 and 2",
"anyOf": [
{
"$ref": "#/definitions/options1"
},
{
"$ref": "#/definitions/options2"
}
]
}
}
}
However for the schema below the last dropdown does not work
Not working schema with anyOf's
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"options1": {
"type": "string",
"anyOf": [
{
"title": "A",
"const": "a"
},
{
"title": "B",
"const": "b"
}
]
},
"options2": {
"type": "string",
"anyOf": [
{
"title": "C",
"const": "c"
},
{
"title": "D",
"const": "d"
}
]
}
},
"type": "object",
"properties": {
"only1": {
"title": "Only 1",
"$ref": "#/definitions/options1"
},
"only2": {
"title": "Only 2",
"$ref": "#/definitions/options2"
},
"both": {
"title": "1 and 2",
"anyOf": [
{
"$ref": "#/definitions/options1"
},
{
"$ref": "#/definitions/options2"
}
]
}
}
}
The last dropdown is missing here
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
JSON Schema nested allOf/anyOf/oneOf not working
EDIT - It appears to be a bug in IntelliJ IDEA validator. It works in python3-jsonschema, Java Everit, jsonschema.dev. json · validation ...
Read more >JSON schema validation fails if anyOf is nested in oneOf
Gives a "Validates to more than one variant" error, but it is expected to validate without errors. Already verified with other validators.
Read more >Schema in a request allows additional properties
If you are using combining operations for objects with properties, additionalProperties must be true or the combining operations will not work.
Read more >Understanding JSON Schema
4.11.2 anyOf . ... Earlier versions of JSON Schema are not completely ... When you start developing large schemas with many nested and ......
Read more >Jenkins Tutorial — Part 5 — When Conditions - ITNEXT
not , allOf and anyOf are complex conditions that are used in conjunction with conditions. not executes the stage if the nested condition...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think it was meant to be any of with the option 1 / option 2 dropdown.
The only difference that is done from working -> not working is that the schemas with
enum
are switched to usinganyOf
. Both should render the same widget.The current playground examples are working as expected, so this issue can be closed