Skip to content

Commit

Permalink
feat(json-schema): add schema templates
Browse files Browse the repository at this point in the history
Signed-off-by: amadeuszsz <[email protected]>
  • Loading branch information
amadeuszsz committed May 30, 2024
1 parent cbd52ea commit 39410ab
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
53 changes: 53 additions & 0 deletions nebula_ros/schema/example.schema.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "<sensor_type> <sensor_vendor> <sensor_model> parameters.",
"type": "object",
"definitions": {
"<sensor_model>": {
"type": "object",
"properties": {
"example_parameter_1": {
"$ref": "sub/communication.json#/definitions/example_parameter_1"
},
"example_parameter_2": {
"$ref": "sub/communication.json#/definitions/example_parameter_2"
},
"example_parameter_3": {
"$ref": "sub/hardware.json#/definitions/example_parameter_3"
},
"example_parameter_4": {
"$ref": "sub/topic.json#/definitions/example_parameter_4"
},
"example_parameter_5": {
"$ref": "sub/misc.json#/definitions/example_parameter_5"
},
"example_parameter_6": {
"$ref": "sub/<sensor_type>_<vendor>.json#/definitions/example_parameter_6"
}
},
"required": [
"example_parameter_1",
"example_parameter_2",
"example_parameter_3",
"example_parameter_4",
"example_parameter_5",
"example_parameter_6"
],
"additionalProperties": false
}
},
"properties": {
"/**": {
"type": "object",
"properties": {
"ros__parameters": {
"$ref": "#/definitions/<sensor_model>"
}
},
"required": ["ros__parameters"],
"additionalProperties": false
}
},
"required": ["/**"],
"additionalProperties": false
}
29 changes: 29 additions & 0 deletions nebula_ros/schema/sub/type_vendor.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "<sensor_type> <sensor_vendor> parameters.",
"type": "object",
"definitions": {
"sensor_model": {
"$ref": "hardware.json#/definitions/sensor_model",
"enum": [
"<sensor_model_1>",
"<sensor_model_2>"
]
},
"example_parameter_1": {
"type": "integer",
"default": 42,
"readOnly": true,
"description": "Exclusive parameter only for specific sensor vendor."
},
"example_parameter_2": {
"$ref": "communication.json#/definitions/example_parameter_2",
"maximum": 100,
"$comment": "Shared parameter, but needs some changes only for this sensor vendor."
},
"example_parameter_3": {
"$ref": "hardware.json#/definitions/example_parameter_3",
"$comment": "Wrong! If no changes declare parameter in schema/<sensor_model>.schema.json."
}
}
}

0 comments on commit 39410ab

Please sign in to comment.