Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Apply NotNull bean-validation to allOf composition #71

Merged
merged 1 commit into from
Jun 20, 2021

Conversation

Tucos
Copy link
Contributor

@Tucos Tucos commented Jun 19, 2021

When using allOf and bean validation, the properties of the composed type do not get annotated with NotNull even though they are marked as required in the schema. While creating and checking a test-case, I came up with a potential fix.
The tests are copied and modified from 2 existing ones.

A type composed using allOf must validate against all listed types. When
these types have required properties, these properties are thus also
required in the composed type.
To correctly annotate those properties with NotNull, set constraints on
the AllOfObjectDataType based on its items.
@hauner
Copy link
Member

hauner commented Jun 20, 2021

I may fix this slightly different but your pull request is good starting point with the tests in place. :-)

Thanks for the report & fix. :-)

@hauner hauner changed the base branch from master to allof-required June 20, 2021 09:38
@hauner hauner merged commit 8acf004 into openapi-processor:allof-required Jun 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apply @NotNull bean-validation to allOf composition
2 participants