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

[java] Appropriate instantiation of model with dynamic properties #6052

Merged
merged 2 commits into from
Aug 23, 2020

Conversation

jimschubert
Copy link
Member

This is an intermediary work around for issues such as #3456.
This fixes #5920.

There's still an issue with applying the import of HashMap when referencing a map-like type. For an example of the issue, generate with the new mapSchemas.yaml test file and inspect the FreeformObjectTypes type.

Applying container import logic similar to what's done in DefaultCodegen:

// TODO revise the logic to include map
if (cp.isContainer) {
    addImport(m, typeMapping.get("array"));
}

for map does not work as expected because Java defines the type mapping as java.util.Map and the instantiation type as java.util.HashMap. It seems like the above snippet in DefaultCodegen might need to account for both the type mapping and the instantiation type when modifying a model's imports.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@auto-labeler
Copy link

auto-labeler bot commented Apr 25, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@jimschubert
Copy link
Member Author

cc @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @bkabrda

cc @OpenAPITools/generator-core-team

@jimschubert jimschubert added this to the 5.0.0 milestone May 10, 2020
@jimschubert
Copy link
Member Author

Bumping this for review before I fix merge conflicts

@robmartin-scibite
Copy link

Any update? This is causing real issues on a project im working on.

@jimschubert
Copy link
Member Author

@robmartin-scibite have you by any chance tested the code in this branch? I'd pinged others and didn't yet get feedback. I can resolve conflicts and maybe push to master so you can evaluate and others can provide feedback.

* master: (720 commits)
  [docs] Update README badges (#7276)
  Update apiInvoker.mustache and sample file for akka-scala client for issue #7258 fix (#7259)
  [Dart] Get all enum values in a list (#7166)
  Update .gitattributes
  [ci] Set ubuntu workflow verification to autoclrf=true, safeclrf=false
  Update check-supported-versions.yaml
  [ci] Update gitattributes and allow skipping docs generation for Windows CI workflows (#7273)
  [core][bug] FILES is now path relative with no prefixes (#7271)
  Update check-supported-versions.yaml
  Update check-supported-versions.yaml (#7268)
  [Java][jersey2] Add jersey injection dependencies (#7240)
  [C][Clang Static Analyzer] Remove the useless variable when assembling URL (#7255)
  Date format dart (#6389)
  minor enhancement to java client generator (#7253)
  typescript: Fix Union Types Import Issue (#6789)
  Modifying the es5 and es6 templates for javascript to handle default values (#6649)
  [python-exp] simplify examples (#7157)
  Support for KumuluzEE microprofile runtime (#5944)
  [C#][netcore] minor improvements and bug fixes (#7244)
  Deprecate Flash (ActionScript) client generator (#7231)
  ...
@jimschubert jimschubert merged commit f70d48e into master Aug 23, 2020
@jimschubert jimschubert deleted the addl-props-import branch August 23, 2020 21:41
jimschubert added a commit to mohamedelhabib/openapi-generator that referenced this pull request Aug 24, 2020
* master: (219 commits)
  [java] Appropriate instantiation of model with dynamic properties (OpenAPITools#6052)
  [docs] Update README badges (OpenAPITools#7276)
  Update apiInvoker.mustache and sample file for akka-scala client for issue OpenAPITools#7258 fix (OpenAPITools#7259)
  [Dart] Get all enum values in a list (OpenAPITools#7166)
  Update .gitattributes
  [ci] Set ubuntu workflow verification to autoclrf=true, safeclrf=false
  Update check-supported-versions.yaml
  [ci] Update gitattributes and allow skipping docs generation for Windows CI workflows (OpenAPITools#7273)
  [core][bug] FILES is now path relative with no prefixes (OpenAPITools#7271)
  Update check-supported-versions.yaml
  Update check-supported-versions.yaml (OpenAPITools#7268)
  [Java][jersey2] Add jersey injection dependencies (OpenAPITools#7240)
  [C][Clang Static Analyzer] Remove the useless variable when assembling URL (OpenAPITools#7255)
  Date format dart (OpenAPITools#6389)
  minor enhancement to java client generator (OpenAPITools#7253)
  typescript: Fix Union Types Import Issue (OpenAPITools#6789)
  Modifying the es5 and es6 templates for javascript to handle default values (OpenAPITools#6649)
  [python-exp] simplify examples (OpenAPITools#7157)
  Support for KumuluzEE microprofile runtime (OpenAPITools#5944)
  [C#][netcore] minor improvements and bug fixes (OpenAPITools#7244)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG][JAVA] Referencing Object with additionalProperties fails to compile with incorrect default value
2 participants