Skip to content

Instantly share code, notes, and snippets.

@chendrix
Last active January 9, 2025 17:01
Show Gist options
  • Save chendrix/350c20415559af4e279e582ccbf39232 to your computer and use it in GitHub Desktop.
Save chendrix/350c20415559af4e279e582ccbf39232 to your computer and use it in GitHub Desktop.
UCAST Expanded Syntax JSON Schema
{
"type": "compound",
"operator": "and",
"value": [
{
"type": "field",
"field": "tickets.assignee",
"operator": "eq",
"value": "Alice Zimmerman"
},
{
"type": "field",
"field": "tickets.severity",
"operator": "in",
"value": [1, 2]
}
]
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "UCAST expanded syntax",
"description": "UCAST expanded syntax that is compatible with AuthZen supported integrations",
"$defs": {
"compoundExpression": {
"type": "object",
"properties": {
"type": { "const": "compound" },
"operator": {
"anyOf": [
{ "const": "and" },
{ "const": "or" }
]
},
"value": {
"type": "array",
"items": { "$ref": "#" }
}
},
"required": ["type", "operator", "value"]
},
"fieldExpression": {
"type": "object",
"properties": {
"type": { "const": "field" },
"field": { "type": "string" },
"operator": { "enum": ["eq", "ne", "lt", "lte", "gt", "gte", "in", "nin"] },
},
"required": ["type", "field", "operator", "value"],
"allOf": [
{
"if": { "properties": { "operator": { "const": "eq" }} },
"then": { "properties": { "value": { "type": ["string", "number", "boolean", "null"] }}}
},
{
"if": { "properties": { "operator": { "const": "ne" }} },
"then": { "properties": { "value": { "type": ["string", "number", "boolean", "null"] }}}
},
{
"if": { "properties": { "operator": { "const": "lt" }} },
"then": { "properties": { "value": { "type": "number" }}}
},
{
"if": { "properties": { "operator": { "const": "lte" }} },
"then": { "properties": { "value": { "type": "number" }}}
},
{
"if": { "properties": { "operator": { "const": "gt" }} },
"then": { "properties": { "value": { "type": "number" }}}
},
{
"if": { "properties": { "operator": { "const": "gte" }} },
"then": { "properties": { "value": { "type": "number" }}}
},
{
"if": { "properties": { "operator": { "const": "in" }} },
"then": { "properties": { "value": { "type": ["array"] }}}
},
{
"if": { "properties": { "operator": { "const": "nin" }} },
"then": { "properties": { "value": { "type": ["array"] }}}
}
]
},
},
"type": "object",
"anyOf": [
{ "$ref": "#/$defs/compoundExpression" },
{ "$ref": "#/$defs/fieldExpression" }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment