Skip to content

Conversation

@MatanRubin
Copy link
Contributor

according to the help message setting dateLibrary to 'legacy' should
make the code generator use java.util.Date.
before this change, when setting dateLibrary to 'legacy' made the
generator use javax.xml.datatype.XMLGregorianCalendar.
now, the generator uses java.util.Date such that the documentation and
behavior are consistent.

…dateLibrary=legacy

according to the help message setting dateLibrary to 'legacy' should
make the code generator use java.util.Date.
before this change, when setting dateLibrary to 'legacy' made the
generator use javax.xml.datatype.XMLGregorianCalendar.
now, the generator uses java.util.Date such that the documentation and
behavior are consistent.
@MatanRubin
Copy link
Contributor Author

@wing328 and @hiveship, I thought this was the only change needed to make codegen work as documented, but now I see other things that I do not understand, maybe you guys could help shed some light...

For example, in JavaCXFServerCodegen +80 I see the following:

        typeMapping.put("date", "LocalDate");
        importMapping.put("LocalDate", "org.joda.time.LocalDate");

This forces the user to use joda time without regard to what was set in the dateLibrary configuration.

I see the same thing in JavaCXFClientCodegen.java and JavaJAXRSSpecServerCodegen.java.
Am I missing something? My inclination is to remove these type and import mappings altogether...

Thanks in advance for your assistance.

@wing328
Copy link
Contributor

wing328 commented Feb 6, 2017

I think those datetime option has been added to Java API client but not for all Java server generators.

cc @cbornet to see if he's any input on this.

@wing328 wing328 added this to the v2.2.2 milestone Feb 13, 2017
@wing328 wing328 modified the milestones: v2.2.2, v2.2.3 Feb 22, 2017
@jfiala
Copy link
Contributor

jfiala commented Mar 5, 2017

The reason for the usage of javax.xml.datatype.XMLGregorianCalendar is that this is the default for the CXF XML based processing.

For CXF I think there should be more flavours:

  • legacy = javax.xml.datatype.XMLGregorianCalendar as this is the default date type used by CXF itself using wadl2java
  • java8
  • joda
  • java.util.Date?

If there is support for java.util.Date needed, I think this should be done as a fourth library.

The current implementation at master though is actually a mixture of joda and XMLGregorianCalendar as @MatanRubin wrote, so a cleanup is a good idea.

@wing328
Copy link
Contributor

wing328 commented Mar 6, 2017

@jfiala thanks for reviewing the change

@MatanRubin thanks for the PR, which has been merged into master.

@wing328 wing328 merged commit 899ef8f into swagger-api:master Mar 6, 2017
@ePaul ePaul mentioned this pull request Mar 26, 2017
3 tasks
spr3nk3ls pushed a commit to spr3nk3ls/swagger-codegen that referenced this pull request Mar 28, 2017
…dateLibrary=legacy (swagger-api#4724)

according to the help message setting dateLibrary to 'legacy' should
make the code generator use java.util.Date.
before this change, when setting dateLibrary to 'legacy' made the
generator use javax.xml.datatype.XMLGregorianCalendar.
now, the generator uses java.util.Date such that the documentation and
behavior are consistent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants