-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect @Nullable JSR305 annotations generated when using 'required' array #906
Milestone
Comments
jrehwaldt
added a commit
to jrehwaldt/jsonschema2pojo
that referenced
this issue
Sep 17, 2018
This depends on joelittlejohngh-917 in order to know if a rule is applied top-level or sub-level. Alternatively, if joelittlejohngh-906 is fixed by providing sub-schemas for sub-levels this could be used to check nesting.
This was referenced Sep 17, 2018
jrehwaldt
added a commit
to jrehwaldt/jsonschema2pojo
that referenced
this issue
Sep 18, 2018
jrehwaldt
added a commit
to jrehwaldt/jsonschema2pojo
that referenced
this issue
Sep 18, 2018
…Rule already suggests). The relevant bits are in `SchemaRule#L79`, where a child schema is obtained and passed down the rule tree as the schema for the relevant section. This seems to be the expected behavior by `NotRequiredRule`, among others. Changes `Schema` to keep reference to its parent `Schema` instead of parent `JsonNode`. This means `Schema(id, JsonNode content, JsonNode parentContent)` is replaced by `Schema(id, JsonNode content, Schema parent)`. `Schema#getParent` still returns _self_ as did `#getParentContent` previously. Fixes joelittlejohngh-906 (JSR305 bug) and depends on joelittlejohngh-921 (integration tests for JSR305 bug)
joelittlejohn
changed the title
Incorrect JSR305 annotations generated
Incorrect @Nullable JSR305 annotations generated when using 'required' array
Sep 19, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, the rule
NotRequiredRule
generates incorrect@Nullable
annotations for fields that get correctly generated with@Nonnull
. This happens only on nested objects, due to broken logic for checking therequired
array definition. When retrieving the schema content we get the root schema instead of the relevant sub schema and therefore the implementation checks against an incorrect hierarchy within the schema.Schema
Behaviour
(Look for
HERE
inSubArray
)Expected
Possible solutions
parentContent
andcontent
is already there, but never used. I think this would be the correct solution.NotRequiredRule
for all fields that do not getRequiredRule
called instead of this separate handling as it stands now. Haven't looked into it.RuleFactory
to return NoopRule for NotRequiredRule and extendObjectRule
to add@Nullable
to all fields not annotated with@Nonnull
after the original ObjectRule is done.The text was updated successfully, but these errors were encountered: