Stream: conformance
Topic: JSON Schema: Validation of Array of Enums
Julius Severin (Nov 02 2020 at 14:06):
We might have found a bug in the JSON Schemas. For arrays of enums the schema is written in the following manner:
{
"title": "enum-array",
"type": "array",
"enum": ["one", "three"],
"items": {"type": "string"}
}
This results in the validator checking for the type of an array first and then compares the enum array with the indiviual items in the array. As an array is compared with a string this always results in the validation failing.
{
"title": "enum-array",
"type": "array",
"items": {
"type": "string",
"enum":["one", "three"]
}
}
This seems to be the way those structures should be modeled in JSON schemas.
One example in FHIR would be ElemenDefinition.representation in STU3.
Lloyd McKenzie (Nov 02 2020 at 14:09):
Are you looking at the schemas as they're published in R4? The JSON schemas published in STU3 are known to be broken (and won't be fixed)
Julius Severin (Nov 02 2020 at 16:21):
Thank you. You are right, this is fixed for R4.
Last updated: Apr 12 2022 at 19:14 UTC