Skip to content

[JAVA] Server codegen for jaxrs fails if java8 date library used #7123

@slarti-b

Description

@slarti-b
Description

Generated a server codegen using jaxrs as language. The JacksonJsonProvider is invalid:

The import com.fasterxml.jackson.datatype.jsr310 cannot be resolved

I had the following two lines in my config file that i fed to swagger codegen:

"dateLibrary": "java8",
"java8": true,

Removing them generates code without errors. The problem seems to be that it is importing joda not jsr310 in the pom file. If I take the Java 8 version then the pom file includes

<dependency>
  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-joda</artifactId>
  <version>${jackson-version}</version>
</dependency>

even though I'm using Java 8 native time not joda. if I replace
<artifactId>jackson-datatype-joda</artifactId>
with
<artifactId>jackson-datatype-jsr310</artifactId>
then the errors go away.

Swagger-codegen version

2.3.0-SNAPSHOT

Command line used for generation

swagger-codegen generate -i push.yml -o ./ -c codegen.config.json -l jaxrs

codegen.config.json looks like (with unrelated stuff removed):

{
	"serializableModel": true,
	"withXml": true,
	"dateLibrary": "java8",
	"java8": true,
	"useBeanValidation": true,
} 
Steps to reproduce

Generate the codegen
Import into eclipse as maven project or just mvn clean install

Suggest a fix/enhancement

As noted above, the pom dependency is wrong for Java ( I think, so that should b set correctly when the Java 8 datetime is used.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions