Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a potential breaking change with respect to
additionalProperties
handling in TypeBox.History 0.16.x
As of
0.16.x
, an update was introduced to enforceadditionalProperties: false
for allType.Object({...})
andType.Intersect({ ... })
types. The reasoning behind this was that the default data validation over the wire would probably want to disallow unknown properties appearing on the objects validated with TypeBox. From TypeBox's standpoint, this update initial appeared to have minimal implication with respect to compositing and inferring types.Problem
As of the
0.16.x
update, It became clear that the defaultadditionalProperties: false
constraint on object types resulted in a number of unforeseen compositional issues, specifically aroundType.Intersect({ ... })
handling in TypeBox. Consider the following.In addition, the internal JSON schema representation of intersected type C also raised some questions, specifically around "What is the best way to express an inferable schema for C with
additionalProperties:false
constraints".This lead to a lengthy discussion with one of the JSON schema engineers (which can be read about here json-schema-org/json-schema-spec#1087). The main take away from this discussion was that the decision to mandate on
additionalProperties: false
is ultimately a violation of JSON schema architectural principles which has some fairly nasty unforeseen downstream consequences with respect to how JSON schema composition can be leveraged (as above).Update 0.17.x
As of
0.17.x
, as a step towards more sophisticated composition, TypeBox no longer appliesadditionalProperties: false
toType.Object({ ... })
schemas. This change will require users to explicitly disallow unknown properties by passingadditionalProperties: false
on all top level schemas expected to be received over the wire.As for
Type.Dict({})
intersections, TypeBox that may leverageunevaluatedProperties
in draft2019-9
at a later time.