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] Server codegen for jaxrs fails if java8 date library used #7123

Closed
slarti-b opened this issue Dec 6, 2017 · 2 comments
Closed

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

slarti-b opened this issue Dec 6, 2017 · 2 comments

Comments

@slarti-b
Copy link
Contributor

slarti-b commented Dec 6, 2017

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.

@deki
Copy link
Contributor

deki commented Jan 1, 2018

You are right, this is already in place for Jersey. I created a PR to change it.

@wing328
Copy link
Contributor

wing328 commented Jan 28, 2018

@slarti-b the fix by @deki has been merged into master. Please pull the latest master to give it a try.

@wing328 wing328 closed this as completed Jan 28, 2018
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