3

I have a java client in swagger whose swagger.json includes the following:

"updatedTime":{"type":"string","format":"date-time"}

This issue from 2015 says specifying the format as date-time doesn't use Joda DateTime. For my client I want to have the property represented as java.util.Date rather than the Joda representation. I tried using -DdateLibrary=java8, but that prevents the client from using the feign builder when I generate my client using the following command:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://localhost:8080/swagger.json -l java --library feign -DdateLibrary=java8 -o samples/client/my-service/java

How can I specify what data type swagger should use for the response object? In fact on the service, the property is already represented as java.util.Date.

danronmoon
  • 3,814
  • 5
  • 34
  • 56
RagHaven
  • 4,156
  • 21
  • 72
  • 113
  • Have you read this response? https://github.com/swagger-api/swagger-codegen/issues/2386 - I've been experiencing the same problem with java8 `LocalDateTime` generated in `Joda DateTime` on the client site – bl4design Feb 28 '17 at 22:14

1 Answers1

0

Instead of dealing with swagger, we can deal with jackson serializatin add the dependency on pom.xml com.fasterxml.jackson.datatype jackson-datatype-jsr310 2.4.0 and add JodaModule on your ObjectMapper ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JodaModule());

Just go through the link: How to serialize Joda DateTime with Jackson JSON processer?

R Pidugu
  • 490
  • 5
  • 8