Skip to content

Commit

Permalink
fix(schema): correctly nest buttons in application schema (#85)
Browse files Browse the repository at this point in the history
* fix(schema): correctly nested buttons in application schema

* update json schema

---------

Co-authored-by: jjenscodee <[email protected]>
  • Loading branch information
eeberhard and jjenscodee authored Dec 8, 2023
1 parent ba49aab commit c42fe2e
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 62 deletions.
84 changes: 46 additions & 38 deletions docs/static/schemas/1-0-0/application.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
"$ref": "#/properties/on_start/properties/load"
},
"unload": {
"$ref": "#/properties/buttons/properties/on_click/properties/unload"
"$ref": "#/properties/buttons/patternProperties/(^[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]$)|(^[a-zA-Z]$)/properties/on_click/properties/unload"
},
"transition": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
Expand Down Expand Up @@ -806,52 +806,60 @@
"description": "A description of interactive buttons in the application graph",
"type": "object",
"additionalProperties": false,
"properties": {
"display_name": {
"title": "Button Display Name",
"description": "The human-readable name to display on the button",
"type": "string"
},
"on_click": {
"title": "On Click",
"description": "Events that are triggered when the button is pressed",
"patternProperties": {
"(^[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]$)|(^[a-zA-Z]$)": {
"title": "Button",
"description": "A named interactive button",
"type": "object",
"additionalProperties": false,
"properties": {
"load": {
"$ref": "#/properties/on_start/properties/load"
"display_name": {
"title": "Button Display Name",
"description": "The human-readable name to display on the button",
"type": "string"
},
"unload": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Unload",
"description": "Unload a component, hardware interface or controller",
"oneOf": [
{
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"$ref": "#/properties/on_start/properties/load/oneOf/1"
}
"on_click": {
"title": "On Click",
"description": "Events that are triggered when the button is pressed",
"type": "object",
"additionalProperties": false,
"properties": {
"load": {
"$ref": "#/properties/on_start/properties/load"
},
{
"$ref": "#/properties/on_start/properties/load/oneOf/1"
"unload": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Unload",
"description": "Unload a component, hardware interface or controller",
"oneOf": [
{
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"$ref": "#/properties/on_start/properties/load/oneOf/1"
}
},
{
"$ref": "#/properties/on_start/properties/load/oneOf/1"
}
]
},
"call_service": {
"$ref": "#/properties/on_start/properties/call_service"
},
"lifecycle": {
"$ref": "#/properties/on_start/properties/lifecycle"
},
"switch_controllers": {
"$ref": "#/properties/on_start/properties/switch_controllers"
}
]
},
"call_service": {
"$ref": "#/properties/on_start/properties/call_service"
},
"lifecycle": {
"$ref": "#/properties/on_start/properties/lifecycle"
}
},
"switch_controllers": {
"$ref": "#/properties/on_start/properties/switch_controllers"
"position": {
"$ref": "#/properties/on_start/properties/position"
}
}
},
"position": {
"$ref": "#/properties/on_start/properties/position"
}
}
}
Expand Down
56 changes: 32 additions & 24 deletions schemas/applications/schema/buttons.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,45 @@
"description": "A description of interactive buttons in the application graph",
"type": "object",
"additionalProperties": false,
"properties": {
"display_name": {
"title": "Button Display Name",
"description": "The human-readable name to display on the button",
"type": "string"
},
"on_click": {
"title": "On Click",
"description": "Events that are triggered when the button is pressed",
"patternProperties": {
"(^[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]$)|(^[a-zA-Z]$)": {
"title": "Button",
"description": "A named interactive button",
"type": "object",
"additionalProperties": false,
"properties": {
"load": {
"$ref": "events/load.schema.json"
"display_name": {
"title": "Button Display Name",
"description": "The human-readable name to display on the button",
"type": "string"
},
"unload": {
"$ref": "events/unload.schema.json"
"on_click": {
"title": "On Click",
"description": "Events that are triggered when the button is pressed",
"type": "object",
"additionalProperties": false,
"properties": {
"load": {
"$ref": "events/load.schema.json"
},
"unload": {
"$ref": "events/unload.schema.json"
},
"call_service": {
"$ref": "events/call_service.schema.json"
},
"lifecycle": {
"$ref": "events/lifecycle.schema.json"
},
"switch_controllers": {
"$ref": "events/switch_controllers.schema.json"
}
}
},
"call_service": {
"$ref": "events/call_service.schema.json"
},
"lifecycle": {
"$ref": "events/lifecycle.schema.json"
},
"switch_controllers": {
"$ref": "events/switch_controllers.schema.json"
"position": {
"$ref": "common/position.schema.json"
}
}
},
"position": {
"$ref": "common/position.schema.json"
}
}
}

0 comments on commit c42fe2e

Please sign in to comment.