Skip to content

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

@nemecec

Description

@nemecec
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions