From a11ce715ae565757b49bcc9c3a242bab7243d199 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 23 Apr 2021 17:25:07 -0500 Subject: [PATCH] doc: Add JSON Schema --- doc/CMakeLists.txt | 8 + doc/changes/misc_features/mr.785.md | 4 + doc/example_configs/config_v0.schema.json | 228 ++++++++++++++++++ .../config_v0.schema.json.license | 2 + 4 files changed, 242 insertions(+) create mode 100644 doc/changes/misc_features/mr.785.md create mode 100644 doc/example_configs/config_v0.schema.json create mode 100644 doc/example_configs/config_v0.schema.json.license diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index dff5e83ff..d6b248ba7 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -29,6 +29,14 @@ if(BUILD_DOC) # request to configure the file configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + # copy the schema + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/example_configs/config_v0.schema.json + ${CMAKE_CURRENT_BINARY_DIR}/html/config_v0.schema.json + @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/example_configs/config_v0.schema.json.license + ${CMAKE_CURRENT_BINARY_DIR}/html/config_v0.schema.json.license + @ONLY) + # note the option ALL which allows to build the docs together with the application add_custom_target(doc_doxygen ALL COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} diff --git a/doc/changes/misc_features/mr.785.md b/doc/changes/misc_features/mr.785.md new file mode 100644 index 000000000..c7fae496b --- /dev/null +++ b/doc/changes/misc_features/mr.785.md @@ -0,0 +1,4 @@ +--- +- issue.82 +--- +Add JSON Schema for config files. diff --git a/doc/example_configs/config_v0.schema.json b/doc/example_configs/config_v0.schema.json new file mode 100644 index 000000000..d066635f3 --- /dev/null +++ b/doc/example_configs/config_v0.schema.json @@ -0,0 +1,228 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "title": "Monado configuration file schema v0", + "type": "object", + "properties": { + "$schema": { + "type": "string", + "title": "JSON Schema directive", + "default": "https://monado.pages.freedesktop.org/monado/config_v0.schema.json" + }, + "active": { + "type": "string", + "title": "Name of the active config object", + "description": "Must match a key in the top-level object. Only config data in that object will be used.", + "$comment": "have omitted 'none' because it primarily exists for environment overrides: just leave out this key in the json for 'none'", + "enum": [ + "tracking", + "remote" + ] + }, + "tracking": { + "$ref": "#/definitions/tracking" + }, + "remote": { + "$ref": "#/definitions/remote" + } + }, + "definitions": { + "remote": { + "title": "Remote device configuration", + "required": [ + "version" + ], + "properties": { + "port": { + "type": "integer" + }, + "version": { + "type": "integer", + "title": "Remote config file schema version", + "enum": [ + 0 + ] + } + } + }, + "tracking": { + "title": "Tracking configuration", + "required": [ + "version" + ], + "properties": { + "version": { + "type": "integer", + "title": "Tracking config file schema version", + "enum": [ + 0 + ] + }, + "tracking_overrides": { + "$ref": "#/definitions/tracking_overrides" + }, + "camera_name": { + "type": "string" + }, + "camera_mode": { + "type": "integer" + }, + "camera_type": { + "type": "string", + "enum": [ + "regular_mono", + "regular_sbs", + "ps4", + "leap_motion" + ] + }, + "calibration_path": { + "type": "string" + }, + } + }, + "tracking_overrides": { + "title": "Tracking overrides", + "type": "array", + "items": { + "$ref": "#/definitions/tracking_override" + } + }, + "tracking_override": { + "type": "object", + "title": "Tracking override object", + "required": [ + "target_device_serial", + "tracker_device_serial", + "type" + ], + "properties": { + "target_device_serial": { + "title": "Target Device Serial", + "$ref": "#/definitions/device_serial" + }, + "tracker_device_serial": { + "title": "Tracker Device Serial", + "$ref": "#/definitions/device_serial" + }, + "type": { + "type": "string", + "enum": [ + "direct", + "attached" + ] + }, + "offset": { + "type": "object", + "title": "Tracking offset", + "default": { + "orientation": { + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "position": { + "x": 0, + "y": 0, + "z": 0 + } + }, + "required": [ + "orientation", + "position" + ], + "properties": { + "orientation": { + "$ref": "#/definitions/quaternion" + }, + "position": { + "title": "Position offset", + "$ref": "#/definitions/vector3" + } + } + }, + "xrt_input_name": { + "type": "string", + "enum": [ + "XRT_INPUT_HYDRA_POSE", + "XRT_INPUT_TOUCH_AIM_POSE", + "XRT_INPUT_SIMPLE_AIM_POSE", + "XRT_INPUT_GENERIC_HEAD_DETECT", + "XRT_INPUT_SIMPLE_GRIP_POSE", + "XRT_INPUT_INDEX_GRIP_POSE", + "XRT_INPUT_VIVE_GRIP_POSE", + "XRT_INPUT_PSMV_AIM_POSE", + "XRT_INPUT_WMR_AIM_POSE", + "XRT_INPUT_WMR_GRIP_POSE", + "XRT_INPUT_PSMV_BODY_CENTER_POSE", + "XRT_INPUT_HAND_AIM_POSE", + "XRT_INPUT_INDEX_AIM_POSE", + "XRT_INPUT_DAYDREAM_POSE", + "XRT_INPUT_GENERIC_HEAD_POSE", + "XRT_INPUT_PSMV_BALL_CENTER_POSE", + "XRT_INPUT_GO_GRIP_POSE", + "XRT_INPUT_TOUCH_GRIP_POSE", + "XRT_INPUT_HAND_GRIP_POSE", + "XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT", + "XRT_INPUT_GENERIC_HAND_TRACKING_LEFT", + "XRT_INPUT_GENERIC_TRACKER_POSE", + "XRT_INPUT_PSMV_GRIP_POSE", + "XRT_INPUT_GO_AIM_POSE", + "XRT_INPUT_VIVE_AIM_POSE" + ], + "default": "XRT_INPUT_GENERIC_TRACKER_POSE" + } + } + }, + "device_serial": { + "type": "string", + "title": "Device serial", + "description": "The unique string assigned to a particular instance of a device by the driver." + }, + "quaternion": { + "type": "object", + "title": "Quaternion", + "description": "Should be normalized (length == 1) to represent rotation", + "properties": { + "x": { + "type": "number" + }, + "y": { + "type": "number" + }, + "z": { + "type": "number" + }, + "w": { + "type": "number" + } + }, + "required": [ + "x", + "y", + "z", + "w" + ] + }, + "vec3": { + "type": "object", + "title": "Vector3", + "properties": { + "x": { + "type": "number" + }, + "y": { + "type": "number" + }, + "z": { + "type": "number" + } + }, + "required": [ + "x", + "y", + "z" + ] + } + } +} diff --git a/doc/example_configs/config_v0.schema.json.license b/doc/example_configs/config_v0.schema.json.license new file mode 100644 index 000000000..a1d1e58cc --- /dev/null +++ b/doc/example_configs/config_v0.schema.json.license @@ -0,0 +1,2 @@ +Copyright 2021, Collabora, Ltd. +SPDX-License-Identifier: CC0-1.0