Hi *,
we currently try to use a conditional schema by using if ... then ....
We have two types of servers (“publicCloud” and “privateCloud”). Both have the same property “cpuCount” but for the privateCloud we set a maximum of 5 CPU and for the publicCloud Server we set a maximum of 2 CPU. They also have different descriptions in the JsonSchema.
This example is extremly simplified, our real example is much more complex.
JsonSchema
{
"type": "object",
"properties": {
"cloudType": {
"type": "string",
"default": "yes",
"enum": [
"private",
"public"
]
},
"infrastructure": {
"allOf": [
{
"if": {
"properties": {
"cloudType": {
"const": "private"
}
}
},
"then": {
"$ref": "#/$defs/privateCloud"
}
},
{
"if": {
"properties": {
"cloudType": {
"const": "public"
}
}
},
"then": {
"$ref": "#/$defs/publicCloud"
}
}
]
}
},
"$defs": {
"publicCloud": {
"type": "object",
"title": "Public Cloud Server",
"properties": {
"cpuCount": {
"type": "number",
"description": "cpu count on PUBLIC cloud",
"maximum": 2
}
}
},
"privateCloud": {
"type": "object",
"title": "Private Cloud Server",
"properties": {
"cpuCount": {
"type": "number",
"description": "cpu count on PRIVATE cloud",
"maximum": 5
}
}
}
}
}
In our uiSchema we have a dropdown (enum) to select the cloud type.
When the cloudType is “private” it should use
- the maximum value: 5
- and description: cpu count on PRIVATE cloud
When the cloudType is “public” it should use
- the maximum value: 2
- and description: cpu count on PUBLIC cloud
Ui Schema
{
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/cloudType"
},
{
"type": "Control",
"scope": "#/properties/infrastructure/properties/cpuCount",
"options": {
"showUnfocusedDescription": true
}
}
]
}
But the result we get is different:
- the form is always showing us the description of the private cloud object
- the form also only uses the maximum of the private cloud object
Is there any solution that jsonforms resolves the schema correctly?
Best Regards
Sebastian
