You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This schema defines one fixed property (test_property01) and then another property using conditional schema composition. The additional property depends on the value of test_property01:
if test_property01 = "myvalue1", then the additional property test_propertyA is added
if test_property01 = "myvalue2", then the additional property test_propertyB is added
Important additional constraint: no other properties are allowed in the whole schema. In other words, this schema will validate an instance in one of the following cases:
If test_property01 = "myvalue1", the instance contains only
test_property01 test_propertyA
and no other properties.
If test_property01 = "myvalue2", the instance contains only
test_property01 test_propertyB
and no other properties.
The constraint "no other properties" is achieved by adding additionalProperties: false to every conditional branch. In order for this to work, however, the existing property test_property01 must be "propagated" to every branch by adding it to the properties block of every branch as "test_property01": true.
Expectation: the property test_property01 is displayed only once in the rendered document. It is omitted from the list of properties in every allOf branch because it is already defined in the parent schema and is merely propagated from it.
Actual result: the rendered document displays the property test_property01 three times: once in the root schema and once in every allOf branch.
Note: the not-yet-supported unevaluatedProperties: false removes the need to propagate properties. However, in many cases the older construct presented above is more preferable because validators produce cleaner error messages (without any cascaded secondary errors).
The text was updated successfully, but these errors were encountered:
Consider the following schema:
Click to expand
This schema defines one fixed property (
test_property01
) and then another property using conditional schema composition. The additional property depends on the value oftest_property01
:test_property01 = "myvalue1"
, then the additional propertytest_propertyA
is addedtest_property01 = "myvalue2"
, then the additional propertytest_propertyB
is addedImportant additional constraint: no other properties are allowed in the whole schema. In other words, this schema will validate an instance in one of the following cases:
If
test_property01 = "myvalue1"
, the instance contains onlytest_property01
test_propertyA
and no other properties.
If
test_property01 = "myvalue2"
, the instance contains onlytest_property01
test_propertyB
and no other properties.
The constraint "no other properties" is achieved by adding
additionalProperties: false
to every conditional branch. In order for this to work, however, the existing propertytest_property01
must be "propagated" to every branch by adding it to theproperties
block of every branch as"test_property01": true
.Expectation: the property
test_property01
is displayed only once in the rendered document. It is omitted from the list of properties in everyallOf
branch because it is already defined in the parent schema and is merely propagated from it.Actual result: the rendered document displays the property
test_property01
three times: once in the root schema and once in everyallOf
branch.Click to expand
root
root > allOf > item 0
root > allOf > item 0 > then > test_property01
root > allOf > item 0 > then > test_propertyA
root > allOf > item 1
root > allOf > item 1 > then > test_property01
root > allOf > item 1 > then > test_propertyB
root > test_property01
Title: root
combining
Description: Root-level schema
Property
root > allOf > item 0
object
If (test_property01 = "myvalue1")
object
Description: TBD
Property
root > allOf > item 0 > then > test_property01
object
Property
root > allOf > item 0 > then > test_propertyA
string
Description: Test property A
Property
root > allOf > item 1
object
If (test_property01 = "myvalue2")
object
Description: TBD
Property
root > allOf > item 1 > then > test_property01
object
Property
root > allOf > item 1 > then > test_propertyB
string
Description: Test property B
Property
root > test_property01
enum (of string)
Description: Test property 01
Must be one of:
Generated using json-schema-for-humans on 2022-10-27 at 22:37:55 +0000
Note: the not-yet-supported
unevaluatedProperties: false
removes the need to propagate properties. However, in many cases the older construct presented above is more preferable because validators produce cleaner error messages (without any cascaded secondary errors).The text was updated successfully, but these errors were encountered: