Skip to content

Comments

[Java] Unalias type when generating default value for model property#5017

Merged
jimschubert merged 3 commits intoOpenAPITools:masterfrom
zippolyte:hippo/unalias
Sep 2, 2020
Merged

[Java] Unalias type when generating default value for model property#5017
jimschubert merged 3 commits intoOpenAPITools:masterfrom
zippolyte:hippo/unalias

Conversation

@zippolyte
Copy link
Contributor

Follow up to #4527, this fixes the default value that gets generated.

I went with the approach of unaliasing the schema first thing in the getTypeDeclaration, to also fix every usage of that method anywhere else.

Also added the same tests scenario for the toDefaultValue method.

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.

cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10)

@zippolyte
Copy link
Contributor Author

Quick bump. @jimschubert do you think this can still make it to 4.2.3 ?

@zippolyte
Copy link
Contributor Author

@jimschubert @wing328 is this ok to merge ?

@zippolyte
Copy link
Contributor Author

@jimschubert @wing328 bump

@jimschubert
Copy link
Member

Hey, I never got notified of the pings from this PR.
I'm working on the merge conflict and I'll regenerate samples. Everything else looks good. I'm not sure why we weren't unaliasing previously.

* master: (984 commits)
  add structPrefix support to go-experimental (OpenAPITools#7327)
  Add a link to SmartHR Tech Blog (OpenAPITools#7324)
  Revert "Correct allOf with only one child schema (no discriminator)" (OpenAPITools#7323)
  Correct allOf with only one child schema (no discriminator) (OpenAPITools#6901)
  [Go]: Interface definitions for api functions (OpenAPITools#5914)
  Update bug_report.md (OpenAPITools#7320)
  update samples
  [Java][Client] Use java8 OffsetDateTime for clients (OpenAPITools#7190)
  [java] Intro openApiNullable property to enable/disable OpenAPI Jackson Nullable library (OpenAPITools#6154)
  [Spring Boot] update dependencies, mark java8 option as deprecated (OpenAPITools#7306)
  Remove dot in golang type (OpenAPITools#7307)
  [doc] Document usage of post-process file feature (OpenAPITools#7315)
  fix http bear auth documentation for go clinets (OpenAPITools#7312)
  [Extensions][Go][Java] Test x-auth-id-alias (OpenAPITools#6642)
  [php-slim4] Move config to a separate file (OpenAPITools#6971)
  [C][Client][Clang Static Analyzer] Remove the useless free operation for (OpenAPITools#7309)
  Fix typescript-node generation when only models are generated (OpenAPITools#7127)
  update spring config to use java8 (OpenAPITools#7308)
  [C][Client][Clang Static Analyzer] Fix uninitialized argument value (OpenAPITools#7305)
  [Java] remove deprecated jackson classes (OpenAPITools#7304)
  ...
@jimschubert
Copy link
Member

I had to make a small change while merging master into your work… the unalias should honor our generate-alias-as-model functionality. Luckily, your work broke a test at JavaClientCodegenTest#testImportMapping from #3589 which asserted that a private member of a generated file would be the model rather than alias type of String. That was an incorrect assertion as it should only be the case when calling configurator.setGenerateAliasAsModel(true).

I think everything looks good to merge once CI is happy.

@jimschubert jimschubert added this to the 5.0.0 milestone Sep 2, 2020
@jimschubert jimschubert self-assigned this Sep 2, 2020
@jimschubert jimschubert merged commit 91ea6a1 into OpenAPITools:master Sep 2, 2020
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.

3 participants