raml-for-jax-rs icon indicating copy to clipboard operation
raml-for-jax-rs copied to clipboard

Can't get JSR 310 LocalDate to work in raml2jax-rs

Open PeteTh opened this issue 8 years ago • 6 comments

I see that https://github.com/mulesoft/raml-for-jax-rs/issues/141 added support for RAML to JSR310 LocalDate and LocalDateTime.

But despite this I can't get the raml-jaxrs-maven-plugin to generate Java 8 java.time.LocalDate despite trying to follow what was discussed on the related fix,

My .json schema has 2 date properties

  • one with date-time
  • one with date, but both generate Jackson classes with java.util.Date.

Here's my pom.xml, any thoughts what I'm missing ? Definitely building with JDK 8 and I've tried to declare plugin dependencies to the latest versions or jars - see below.


<plugin>
                <groupId>org.raml.plugins</groupId>
                <artifactId>raml-jaxrs-maven-plugin</artifactId>
                <version>1.3.4</version>
                <configuration>
                    <removeOldOutput>true</removeOldOutput>
                    <!-- Use sourcePaths if you want to provide a single RAML file or a 
                        list of RAML files -->
                    <sourceDirectory>${basedir}/src/main/resources/raml</sourceDirectory>
                    <!-- Optionally configure outputDirectory if you don't like the default 
                        value: ${project.build.directory}/generated-sources/raml-JAX-RS -->
                    <!-- outputDirectory>${basedir}/src/main/java</outputDirectory -->
                    <!-- Replace with your package name -->
                    <basePackageName>uk.abc.datatier.jaxrs</basePackageName>
                    <!-- Valid values: 1.1 2.0 -->
                    <jaxrsVersion>2.0</jaxrsVersion>
                    <useJsr303Annotations>true</useJsr303Annotations>
                    <!-- Valid values: jackson1 jackson2 gson none -->
                    <jsonMapper>jackson2</jsonMapper>
                    <removeOldOutput>true</removeOldOutput>
                    <!-- Optionally set extensions to a list of fully qualified names of 
                        classes that implement org.raml.jaxrs.codegen.core.ext.GeneratorExtension -->
                    <!-- for example: <extensions> <param>com.abc.AuthorizationAnnotationExtension</param> 
                        <param>com.abc.ParameterFilterExtension</param> </extensions> Custom annotator 
                        for json schema to pojo convertor <customAnnotator>com.abc.MyCustomAnnotator</customAnnotator> -->
                    <jsonMapperConfiguration>
                        <useLongIntegers>true</useLongIntegers>
                        <dateTimeType>java.time.LocalDateTime</dateTimeType>
                        <dateType>java.time.LocalDate</dateType>
                        <timeType>java.time.LocalTime</timeType>
                    </jsonMapperConfiguration>
                </configuration>

                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>

                <dependencies>

                    <dependency>
                        <groupId>org.jsonschema2pojo</groupId>
                        <artifactId>jsonschema2pojo-core</artifactId>
                        <version>0.4.26</version>
                    </dependency>
                    <dependency>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                        <version>2.7.0</version>
                    </dependency>
                </dependencies>

            </plugin>

PeteTh avatar Oct 12 '16 07:10 PeteTh

First of all you have to use 1.3.5-SNAPSHOT

dmiorandi avatar Oct 12 '16 08:10 dmiorandi

Thanks - where do I find that version https://repository-master.mulesoft.org/nexus/content/repositories/snapshots/org/raml/plugins/jaxrs-raml-maven-plugin/ only seems to have 1.3.4-SNAPSHOT

PeteTh avatar Oct 12 '16 09:10 PeteTh

You can download sources and build yourself (mvn install from root of project to put in you cache), otherwise https://jitpack.io/ is to use git project (version you want) as a snapshot, when mvn jar not available.

dmiorandi avatar Oct 12 '16 09:10 dmiorandi

Ok great it's working if I build from source of the master branch.

I noticed that the pom version of source on master branch is 1.3.4-SNAPSHOT not 1.3.5-SNAPSHOT.

Any idea when/if you can deploy either a snapshot release or final release to a plugin repository, as don't really want to have build from source on all machines & it looks like this was fixed last year !

PeteTh avatar Oct 12 '16 12:10 PeteTh

I'm just a contributor and I'm waiting too. I had same issue and I built from sources too (and put it on my nexus, one-shot) If you don't want build sources jitpack is the only solution, it does it for you. Usually releases are lazy. I hope that 1.3.5 will release before end of the year but honestly I don't know.

dmiorandi avatar Oct 12 '16 13:10 dmiorandi

Hi,

I am having same issue and using plugin version 2.1.0. Any idea, is <jsonMapperConfiguration> supported in this version? or please help with workaround for it.

java.time.LocalDateTime java.time.LocalDate java.time.LocalTime

Thank you

Regards, Muthu

muthulingapandian avatar Mar 22 '18 10:03 muthulingapandian