I have a JSON Schema that includes a recursive type, and I’m trying to define the UI Schema accordingly. I looked through the documentation on applying UI Schema rules but wasn’t able to figure out how to adapt them to my use case.
The use case involves building an authorization rule set, where a rule can be either:
- Simple: Represents a claim.
- Recursive: A composite rule with “any” or “all” policies.
Depending on the rule type, certain controls should be shown or hidden dynamically. How can I structure my UI Schema to handle this?
Here is a sample JSON Schema:
{
"definitions": {
"authorizationRequirement": {
"type": "object",
"properties": {
"type": {
"description": "The type of authorization requirement to create",
"type": "string",
"enum": [
"claim",
"composite"
]
},
"claimType": {
"description": "The type of the Claim to check. Supports regular expressions",
"type": "string"
},
"claimValue": {
"description": "The value of the Claim to check. Supports regular expressions. If no value is set, the requirement only checks for claim's existence",
"type": "string"
},
"conditionType": {
"description": "The type of condition to perform",
"type": "string",
"enum": [
"all",
"any"
]
},
"requirements": {
"type": "array",
"items": {
"$ref": "#/definitions/authorizationRequirement"
}
}
}
}
},
"type": "object",
"properties": {
"name": {
"description": "The name of the authorization policy to create",
"type": "string",
"minLength": 1
},
"description": {
"description": "The description of the authorization policy to create",
"type": "string"
},
"requirements": {
"description": "A list of authorization requirements",
"type": "array",
"items": {
"$ref": "#/definitions/authorizationRequirement"
}
}
},
"required": [
"name",
"requirements"
]
}
and the UI Schema:
{
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/name"
},
{
"type": "Control",
"scope": "#/properties/description"
},
{
"type": "Control",
"scope": "#/properties/requirements",
"options": {
"detail": {
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/type"
},
{
"type": "HorizontalLayout",
"rule": {
"effect": "SHOW",
"condition": {
"type": "LEAF",
"scope": "#/properties/type",
"expectedValue": "claim"
}
},
"elements": [
{
"type": "Control",
"scope": "#/properties/claimType"
},
{
"type": "Control",
"scope": "#/properties/claimValue"
}
]
},
{
"type": "VerticalLayout",
"rule": {
"effect": "SHOW",
"condition": {
"type": "LEAF",
"scope": "#/properties/type",
"expectedValue": "composite"
}
},
"elements": [
{
"type": "Control",
"scope": "#/properties/conditionType"
},
{
"type": "Control",
"scope": "#/properties/requirements"
}
]
}
]
}
}
}
]
}

