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

[SpringCodeGen] dateLibrary "java8-localdatetime" option is broken #7177

Closed
nemecec opened this issue Dec 13, 2017 · 1 comment
Closed

[SpringCodeGen] dateLibrary "java8-localdatetime" option is broken #7177

nemecec opened this issue Dec 13, 2017 · 1 comment

Comments

@nemecec
Copy link
Contributor

nemecec commented Dec 13, 2017

Description

Using dateLibrary option set to java8-localdatetime is not working as expected in case of spring-mvc library. I would expect the generated object model to use java.time.LocalDateTime but instead, it is using java.time.OffsetDateTime.

AbstractJavaCodeGen contains logic to choose the right dateTime implementation (code) but that is rudely overridden by SpringCodegen (code).

Removing those 4 lines of overriding code from SpringCodegen seems to fix the issue and should not have any adverse side-effect (as Java8 is the default date library anyway in case of SpringCodegen).

I'll prepare a pull request so you can review it.

BTW, I'm aware that using LocalDateTime is not according to Swagger spec, but I'm maintaining an existing API and it will take time to migrate users to start using OffsetDateTime. And the logic to use LocalDateTime is already there, so I think users should have that option available and working as advertised by Swagger Codegen documentation.

Swagger-codegen version

All versions of SpringCodegen that I could see on GitHub.

wing328 pushed a commit that referenced this issue Jan 22, 2018
jimschubert added a commit to jimschubert/swagger-codegen that referenced this issue Jan 22, 2018
* master: (133 commits)
  add a link to ebook (polish version)
  Add R namespace file (swagger-api#7467)
  Add Spring Petstore samples (async, java8-localdatetime) to CircleCI (swagger-api#7468)
  Revised core team members
  Ada code generator corrected: "=>" instead of "->". Fixes swagger-api#7450 (swagger-api#7456)
  Fixes issue swagger-api#7177 (SpringCodeGen dateLibrary "java8-localdatetime" option is ignored). (swagger-api#7178)
  Issue-7438 Fix that prevents generating interfaces when interfaceOnly is false. (swagger-api#7439)
  swagger-api#7093 - Add maven wrapper (swagger-api#7356)
  [csharp] Support arrays of arrays for properties and models (swagger-api#7400)
  [csharp] Fix ToJson to work with composition and polymorphism (swagger-api#7399)
  [csharp] Reference this.Configuration in client api template (swagger-api#7394)
  [JAX-RS][Spec] Removes throws Exception. (swagger-api#7437)
  Use supportsES6 flag in ts compilation for language typescript-angular (swagger-api#7408)
  Fix 7457: [Ada] wrong order for generated structures in *-models.ads (swagger-api#7462)
  Fix 7459: [Ada] wrong JSON in POST operations (swagger-api#7460)
  [erlang-client] Erlang request utils (swagger-api#7257)
  reenable pushing snapshot to maven repo
  Create CODE_OF_CONDUCT.md
  comment out update to docker image
  deleted unnecessary notes (swagger-api#7454)
  ...
viclovsky pushed a commit to viclovsky/swagger-codegen that referenced this issue Jan 23, 2018
@wing328 wing328 closed this as completed Jan 29, 2018
@wing328 wing328 added this to the v2.4.0 milestone Jan 29, 2018
@macjohnny
Copy link
Contributor

@nemecec awesome, thanks for the fix!

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

No branches or pull requests

3 participants