-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String enum strategy #42
Comments
Using draft-07: https://www.jsonschemavalidator.net/s/PqKGCvsE Which could be transformed to draft-04 using Boolean implication, but gets even more verbose... Either way, not going to be very elegant to combine with the main flow_video_register.json or sender_register.json schemas... |
Here's a stab at it... {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Describes Video Flow additional and extensible attributes defined in the NMOS Parameter Registers.",
"title": "Video Flow resource",
// Base definition schema and all of the media type constraints schemas must validate successfully
"allOf": [
{
"description": "Base definition of registered properties",
"properties": {
"bit_rate": {
"description": "Bit rate, in kilobits/second. Integer value expressed in units of 1000 bits per second, rounding up.",
"type": "integer"
},
"profile": {
"description": "Profile. Indicates the subset of coding tools that are in use, as defined for the Flow media type.",
"type": "string"
// no enum here
},
// other properties
}
},
{
// This schema says "if the media type is video/jxsv, then additional property value constraints apply"
// implemented as "either the media type is not video/jxsv or the additional property value constraints apply"
"anyOf": [
{
"not": {
"properties": {
"media_type": {
"enum": [
"video/jxsv"
]
}
}
}
},
// or on one line:
// { "not": { "properties": { "media_type": { "enum": [ "video/jxsv" ] } } } },
{
"description": "Definition of constrained property values for video/jxsv",
"properties": {
"profile": {
"enum": [
"High444.12",
"Main444.12",
"Light444.12",
"Main422.10",
"Light422.10",
// etc.
]
},
"level": {
"enum": [
"1k-1",
"Bayer2k-1",
"2k-1",
"Bayer4k-1",
"4k-1",
"Bayer8k-1",
"4k-2",
// etc.
]
}
}
}
]
},
{
"anyOf": [
{
"not": {
"properties": {
"media_type": {
"enum": [
"video/cats"
]
}
}
}
},
{
"properties": {
"profile": {
"enum": [
"meow",
"purr",
"hiss",
"yowl"
]
}
}
}
]
},
// other media_type constraints schemas
]
} There are pros and cons to factoring that into several files like: {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Describes Video Flow additional and extensible attributes defined in the NMOS Parameter Registers.",
"title": "Video Flow resource",
"allOf": [
{ "$ref": "flow_video_base_register.json" },
{
"anyOf": [
{ "not": { "properties": { "media_type": { "enum": [ "video/jxsv" ] } } } },
{ "$ref": "flow_video_jxsv_register.json" }
]
},
{
"anyOf": [
{ "not": { "properties": { "media_type": { "enum": [ "video/cats" ] } } } },
{ "$ref": "flow_video_cats_register.json" }
]
},
// etc.
]
} |
Of course this technique won't work to validate codec-dependent transport attributes that are held on the Sender, e.g. |
To be considered by @AMWA-TV/nmos-architecture-review group and the NMOS Stream Mappings activity group:
Flow string attributes like
profile
andlevel
haveenum
erated values that are open to extensibility for two reasons:The schemas included in the parameter register wouldn't be very useful if they allowed any
string
value for these attributes, so perhaps there's nothing we can do about the latter point, other than quickly update schemas when that happens?It probably is possible to make the set of permitted
enum
values depend on the Flowmedia_type
value, though that may need a more recent version of JSON Schema than draft-04?The text was updated successfully, but these errors were encountered: