diff --git a/APIs/schemas/README.md b/APIs/schemas/README.md new file mode 100644 index 0000000..e984750 --- /dev/null +++ b/APIs/schemas/README.md @@ -0,0 +1,16 @@ +This directory is for JSON Schemas used in documentation. Some of them were copied from other AMWA NMOS specifications. + +[IS-04 v1.3.2][]: +- [resource_core.json](https://github.com/AMWA-TV/is-04/raw/v1.3.2/APIs/schemas/resource_core.json) + +[BCP-004-01 v1.0.0][]: +- [constraint_set.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/constraint_set.json) +- [param_constraint.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint.json) +- [param_constraint_boolean.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_boolean.json) +- [param_constraint_integer.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_integer.json) +- [param_constraint_number.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_number.json) +- [param_constraint_rational.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_rational.json) +- [param_constraint_string.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_string.json) + +[IS-04 v1.3.2]: https://specs.amwa.tv/is-04/releases/v1.3.2/ +[BCP-004-01 v1.0.0]: https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/ diff --git a/APIs/schemas/constraint_set.json b/APIs/schemas/constraint_set.json new file mode 100644 index 0000000..ab439d3 --- /dev/null +++ b/APIs/schemas/constraint_set.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Constraint Set", + "title": "Constraint Set", + "type": "object", + "minProperties": 1, + "properties": { + "urn:x-nmos:cap:meta:label": { + "description": "Freeform string label for the Constraint Set", + "type": "string" + }, + "urn:x-nmos:cap:meta:preference": { + "description": "This value expresses the relative 'weight' that the Receiver assigns to its preference for the streams satisfied by the associated Constraint Set. The weight is an integer in the range -100 through 100, where -100 is least preferred and 100 is most preferred. When the attribute is omitted, the effective value for the associated Constraint Set is 0.", + "type": "integer", + "default": 0, + "maximum": 100, + "minimum": -100 + }, + "urn:x-nmos:cap:meta:enabled": { + "description": "This value indicates whether a Constraint Set is available to use immediately (true) or whether this is an offline capability which can be activated via some unspecified configuration mechanism (false). When the attribute is omitted its value is assumed to be true.", + "type": "boolean", + "default": true + } + }, + "patternProperties": { + "^urn:x-nmos:cap:(?!meta:)": { + "$ref": "param_constraint.json" + } + } +} diff --git a/APIs/schemas/constraints_active.json b/APIs/schemas/constraints_active.json index b9a9253..539dbec 100644 --- a/APIs/schemas/constraints_active.json +++ b/APIs/schemas/constraints_active.json @@ -10,7 +10,7 @@ "constraint_sets": { "type": "array", "items": { - "$ref": "https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.x/APIs/schemas/constraint_set.json" + "$ref": "constraint_set.json" } } } diff --git a/APIs/schemas/empty_constraints_active.json b/APIs/schemas/empty_constraints_active.json index 6a9627b..a75a5e2 100644 --- a/APIs/schemas/empty_constraints_active.json +++ b/APIs/schemas/empty_constraints_active.json @@ -9,7 +9,7 @@ "constraint_sets": { "type": "array", "items": { - "$ref": "https://raw.githubusercontent.com/AMWA-TV/nmos-receiver-capabilities/v1.0.0/APIs/schemas/constraint_set.json" + "$ref": "constraint_set.json" }, "minItems": 0, "maxItems": 0 diff --git a/APIs/schemas/input.json b/APIs/schemas/input.json index d49dda6..0d915fb 100644 --- a/APIs/schemas/input.json +++ b/APIs/schemas/input.json @@ -4,7 +4,7 @@ "description": "Describes an Input", "title": "Input resource", "allOf": [ - { "$ref": "https://raw.githubusercontent.com/AMWA-TV/nmos-discovery-registration/v1.3.1/APIs/schemas/resource_core.json" }, + { "$ref": "resource_core.json" }, { "type": "object", "required": [ diff --git a/APIs/schemas/output.json b/APIs/schemas/output.json index 47d1fea..0c9ccfc 100644 --- a/APIs/schemas/output.json +++ b/APIs/schemas/output.json @@ -4,7 +4,7 @@ "description": "Describes an Output", "title": "Output resource", "allOf": [ - { "$ref": "https://raw.githubusercontent.com/AMWA-TV/nmos-discovery-registration/v1.3.1/APIs/schemas/resource_core.json" }, + { "$ref": "resource_core.json" }, { "type": "object", "required": [ diff --git a/APIs/schemas/param_constraint.json b/APIs/schemas/param_constraint.json new file mode 100644 index 0000000..0537109 --- /dev/null +++ b/APIs/schemas/param_constraint.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Parameter Constraint", + "title": "Parameter Constraint", + "type": "object", + "anyOf": [ + { "$ref": "param_constraint_string.json" }, + { "$ref": "param_constraint_integer.json" }, + { "$ref": "param_constraint_number.json" }, + { "$ref": "param_constraint_boolean.json" }, + { "$ref": "param_constraint_rational.json" } + ] +} diff --git a/APIs/schemas/param_constraint_boolean.json b/APIs/schemas/param_constraint_boolean.json new file mode 100644 index 0000000..fac6b99 --- /dev/null +++ b/APIs/schemas/param_constraint_boolean.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Boolean Parameter Constraint", + "title": "Boolean Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "boolean" + } + } + } +} diff --git a/APIs/schemas/param_constraint_integer.json b/APIs/schemas/param_constraint_integer.json new file mode 100644 index 0000000..35c5aec --- /dev/null +++ b/APIs/schemas/param_constraint_integer.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes an Integer Parameter Constraint", + "title": "Integer Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "integer" + } + }, + "minimum": { + "type": "integer" + }, + "maximum": { + "type": "integer" + } + } +} diff --git a/APIs/schemas/param_constraint_number.json b/APIs/schemas/param_constraint_number.json new file mode 100644 index 0000000..24a93c1 --- /dev/null +++ b/APIs/schemas/param_constraint_number.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Number Parameter Constraint", + "title": "Number Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "number" + } + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + } +} diff --git a/APIs/schemas/param_constraint_rational.json b/APIs/schemas/param_constraint_rational.json new file mode 100644 index 0000000..31a8db6 --- /dev/null +++ b/APIs/schemas/param_constraint_rational.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Rational Parameter Constraint", + "title": "Rational Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/rational" + } + }, + "minimum": { + "$ref": "#/definitions/rational" + }, + "maximum": { + "$ref": "#/definitions/rational" + } + }, + "definitions": { + "rational": { + "type": "object", + "required": [ + "numerator" + ], + "properties": { + "numerator": { + "type": "integer" + }, + "denominator": { + "type": "integer", + "default": 1 + } + }, + "additionalProperties": false + } + } +} diff --git a/APIs/schemas/param_constraint_string.json b/APIs/schemas/param_constraint_string.json new file mode 100644 index 0000000..a866008 --- /dev/null +++ b/APIs/schemas/param_constraint_string.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a String Parameter Constraint", + "title": "String Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + } + } +} diff --git a/APIs/schemas/resource_core.json b/APIs/schemas/resource_core.json new file mode 100644 index 0000000..4eb583a --- /dev/null +++ b/APIs/schemas/resource_core.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "description": "Describes the foundations of all NMOS resources", + "title": "Base resource", + "required": [ + "id", + "version", + "label", + "description", + "tags" + ], + "properties": { + "id": { + "description": "Globally unique identifier for the resource", + "type": "string", + "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" + }, + "version": { + "description": "String formatted TAI timestamp (:) indicating precisely when an attribute of the resource last changed", + "type": "string", + "pattern": "^[0-9]+:[0-9]+$" + }, + "label": { + "description": "Freeform string label for the resource", + "type": "string" + }, + "description": { + "description": "Detailed description of the resource", + "type": "string" + }, + "tags": { + "description": "Key value set of freeform string tags to aid in filtering resources. Values should be represented as an array of strings. Can be empty.", + "type": "object", + "patternProperties": { + "": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file