Treat unknown properties as invalid + some new helpers #126
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.
In some cases an easy mistake in
ToJSON
orToSchema
instances could make them incompatible while leavingvalidateToJSON
tests passing.The problem is that unknown properties in a JSON object are ignored when
Schema
does not have anadditionalProperties
schema. IfSchema
also does not have any required properties, thenvalidateToJSON
will most certainly pass without a warning or error.Invalid ToJSON-ToSchema Examples
Mixed sum types and
genericDeclareNamedSchemaUnrestricted
Deriving
ToSchema
for mixed sum types is not allowed since 2.1.5 without an unrestricted version:Resulting
ToJSON
andToSchema
instances don't match, and, worse,validateToJSON
is silent:This PR makes this change:
Newtypes for maps with bounded enum keys
When you have a
Map
with just a few possible values for keys, it makes sense to list them (and only them) in your Swagger Schema:However, in this example
ToJSON
andToSchema
don't match, yetvalidateToJSON
is silent:This PR makes this change:
Moreover, this PR introduces helper for this sort of
ToSchema
instances: