skalarsystems / fhirzeug

A Python FHIR specification parser and class generator
Apache License 2.0
17 stars 1 forks source link

Don't allow fields which are not defined in spec #56

Closed trojanowski closed 4 years ago

trojanowski commented 4 years ago

According to https://www.hl7.org/fhir/json.html:

Given the way extensions work, applications reading JSON resources will never encounter unknown properties. However, once an application starts trading with other applications that conform to later versions of this specification, unknown properties may be encountered. Applications MAY choose to ignore unknown properties in order to foster forwards compatibility in this regard, but may also choose not to.

Also, the JSON spec version of the schema defines "additionalProperties": false for all object types.

Right now, unknown fields are ignored, but maybe a better idea is to throw ValidationError if they appear. It could be easily done by adding extra = 'forbid' to the Config class in FHIRAbstractBase.