Stream: implementers
Topic: FHIR R4 JSchema "type"?
John Silva (Nov 11 2019 at 18:24):
Has anyone been using the FHIR R4 JSchema definitions? I notice that many FHIR Resources and DataTypes have the property "type", but that is a keyword in JSchema? How can this work for FHIR's JSchema?
For example, the Location resource has a 'type' property for defining the "Type of function performed".
John Silva (Nov 11 2019 at 18:35):
@Grahame Grieve @Lloyd McKenzie Hmm, same problem with the description property (of Location); description is also a JSchema keyword. https://json-schema.org/understanding-json-schema/reference/generic.html https://json-schema.org/understanding-json-schema/basics.html?highlight=type#the-type-keyword
Grahame Grieve (Nov 11 2019 at 19:32):
I don't understand the issue. type is a keyword in json schema but why would that have anything to do with the use of 'type' in the json described by the schema?
John Silva (Nov 11 2019 at 20:12):
Maybe it's the toolset I'm using but when the JSchema definition contains:
"type":{ "description":"Indicates the type of function performed at the location.", "items":{ }, "type":"array" },
When the above is loaded in the JSchema (e.g. for Location Resource) the JSchema lib we're using thinks the property name "type" is the JSchema keyword "type" and errors out doing the validation of an incoming JSON resource.
This is why I asked if anyone has actually tried the FHIR JSchema definitions to find out if anyone else has seen this problem. BTW, we're using the NewtonSoft JSchema library. Are there other JSchema libraries that people have tried?
Grahame Grieve (Nov 11 2019 at 20:14):
well, I'm pretty sure that json schema did not intend to prohibit the use of 'type' and 'description' (and 'min' and 'max') in json documents. And that this is an error in the tooling.
Grahame Grieve (Nov 11 2019 at 20:15):
the FHIR build tooling uses org.everit.json.schema
John Silva (Nov 11 2019 at 20:16):
Thanks @Grahame Grieve - do you know of any other JSchema libraries that people are using? (or are most using the Java Validator so don't see this.)
Grahame Grieve (Nov 11 2019 at 20:18):
Obviously the java validator is a much better validator because it knows more about FHIR but lots of people have considerable json schema usage. I've heard of the use of
- json.NET schema
- everit
- ajv
- the online JSON Schema validator
But most discussions are in the context of openAPI
Last updated: Apr 12 2022 at 19:14 UTC