Skip to content
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

Fix getter methods for Java model with additionalProperties #8245

Merged
merged 1 commit into from
Jun 9, 2018
Merged

Fix getter methods for Java model with additionalProperties #8245

merged 1 commit into from
Jun 9, 2018

Conversation

stianlik
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. Did not generate petstore example because that would significantly increase the diff
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language. No members left in the technical committee for Java, including @HugoMario because he has merged other PRs

Description of the PR

When a model class is configured with additionalProperties, getters for non-dynamic properties always return null because values have been set as properties of the map instead of the class. As a workaround, this commit ensures that we these values are retrieved from the underlying map.

This (partially) fixes #4970, fixes #5259, and fixes #5187

The issue of additionalProperties is not completely solved by this PR, however, we support the situation where additionalProperties is of type object, or all fields are of the same type as additionalProperties. I.e. it will not work if we have properties of type integer and additionalProperties of type array due to incorrect type casting.

    When a model class is configured with additionalProperties, getters for
    non-dynamic properties always return null because values have been set as properties
    of the map instead of the class. As a workaround, this commit ensures that we these
    values are available in getters as well.

    This fixes #4970, fixes #5259, and fixes #5187
@HugoMario
Copy link
Contributor

thanks @stianlik !!!

@fralalonde
Copy link
Contributor

As I suggested in #5187, could the solution be to flag-enable this jackson-enhanced behavior to preserve compatibility with gson and resteasy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment