FHIR Chat · JSON $schema · implementers

Stream: implementers

Topic: JSON $schema


view this post on Zulip Rik Smithies (Apr 19 2019 at 22:07):

I've been playing with JSON schema for the first time.
There seems to be some sort of semi-standard use of $schema to specify the schema file location.
And fhir.schema.json itself uses this.
But this doesn't seem to be allowed in a FHIR JSON instance.
Is there a good reason why this shouldn't be allowed?
In know we don't encourage the use of hard coded schema references, but they are useful when testing, and are schema valid with XSD.

view this post on Zulip Lloyd McKenzie (Apr 19 2019 at 22:41):

I presume for the same reason we prohibit schema references in XML - references to external file locations pose a security risk (whether as a vector for harmful code or as a means of externally monitoring data access)

view this post on Zulip Lloyd McKenzie (Apr 19 2019 at 22:42):

When testing/authoring, you can always throw the schema reference in and ignore the validation message. In my IG framework, I strip off the schema declarations as part of the generation process so I can use them when authoring but produce compliant instances in the publication.

view this post on Zulip Grahame Grieve (Apr 19 2019 at 23:37):

semi-standard use of $schema to specify the schema file location.

I've given up trying to undestand json schema on this. The json schema specification explicitly says that this is not true. Most users of json schema (including openAPI) explicitly say that this is true. Json schema tools are all over the place on how it works

view this post on Zulip Rik Smithies (Apr 19 2019 at 23:55):

My choices are: no schema and no validation, or schema and validation and always one error. Ignoring one error is not so nice, because you then have to check which error it was.
Tools don't seem to be good at associating the schemas other ways.
I would like to add in a declaration that allows $schema, in a special weaker version of the fhir.schema.json file, but haven't been able to figure out how.

view this post on Zulip Grahame Grieve (Apr 20 2019 at 00:05):

Is there any discussion about json schema allowing a reference to itself? it never occurred to me that this would be a problem. I’m not familiar with it from XML schema


Last updated: Apr 12 2022 at 19:14 UTC