Skip to content

Commit

Permalink
Merge pull request #129 from AMWA-TV/schemas-self-contained
Browse files Browse the repository at this point in the history
Make IS-11 schemas self-contained
  • Loading branch information
N-Nagorny committed Jul 3, 2023
2 parents e0bb75b + c442a94 commit a9e6b6b
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 4 deletions.
16 changes: 16 additions & 0 deletions APIs/schemas/README.md
Original file line number Diff line number Diff line change
@@ -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/
30 changes: 30 additions & 0 deletions APIs/schemas/constraint_set.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
2 changes: 1 addition & 1 deletion APIs/schemas/constraints_active.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion APIs/schemas/empty_constraints_active.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion APIs/schemas/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion APIs/schemas/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
13 changes: 13 additions & 0 deletions APIs/schemas/param_constraint.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
15 changes: 15 additions & 0 deletions APIs/schemas/param_constraint_boolean.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
21 changes: 21 additions & 0 deletions APIs/schemas/param_constraint_integer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
21 changes: 21 additions & 0 deletions APIs/schemas/param_constraint_number.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
39 changes: 39 additions & 0 deletions APIs/schemas/param_constraint_rational.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
15 changes: 15 additions & 0 deletions APIs/schemas/param_constraint_string.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
45 changes: 45 additions & 0 deletions APIs/schemas/resource_core.json
Original file line number Diff line number Diff line change
@@ -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 (<seconds>:<nanoseconds>) 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"
}
}
}
}
}
}

0 comments on commit a9e6b6b

Please sign in to comment.