mulesoft-labs / raml-for-jax-rs

This project is all about two way transformation of JAX-RS-annotated Java code to RAML API description and back.
Other
295 stars 181 forks source link

No support of useLongIntegers #92

Closed getmehrotra closed 9 years ago

getmehrotra commented 9 years ago

Hi, The plugin converts Query Parameters of type "integer" as Long in Rest interface. While if we have JSON schema defining request or response and have integer type parameter then it converted as java Integer type. There is no way in the plugin to define useLongInteger property for JSON to Java conversion.

While JSONSchema2POJO supports the parameter.

ddossot commented 9 years ago

From this: https://github.com/mulesoft/raml-for-jax-rs/blob/master/raml-to-jaxrs/maven-plugin/src/main/java/org/raml/jaxrs/codegen/maven/RamlJaxrsCodegenMojo.java#L147-L153 I think this option is actually supported...

Try adding:

<jsonMapperConfiguration>
  <useLongIntegers>true</useLongIntegers>
</jsonMapperConfiguration>

to the plug-in configuration.

getmehrotra commented 9 years ago

I am using Gradle Plugin. Is this support there as well? How do i need to give this in gradle? From the groovy code for gradle extension it seems gradle plugin doesn't give same level of configurations.

KonstantinSviridov commented 9 years ago

Hi, @getmehrotra

RAML 0.8 specification does not say anything about integer type bounds, so, by default, we have to convert it to long. On the other side, XSD does not have such type as long.

So, in order to make the resulting types the same, we can introduce a generation parameter which says how to treat integer in RAML. We shall implement it in nearest future.

Regards, Konstantin.

ddossot commented 9 years ago

@KonstantinSviridov I think @getmehrotra is concerned about JSON Schema, not RAML, because he said "useLongInteger property for JSON to Java conversion".

sumveds commented 9 years ago

Can it be supported in a SNAPSHOT version?

sumveds commented 9 years ago

Ah! Adding

<jsonMapperConfiguration>
  <useLongIntegers>true</useLongIntegers>
</jsonMapperConfiguration>

to configuration works fine. Thank you @ddossot

KonstantinSviridov commented 9 years ago

@ddossot, thanks for correcting me.

@getmehrotra Seems like it's enough to create a Map<String,String> jsonMapperConfiguration field for the groovy.org.raml.jaxrs.gradle.RamlExtension class and then, inside the org.raml.jaxrs.gradle.codegen.CodeGeneratorTask.generate() method, pass its value into the Configuration utilized by the generator.

Does it sound fine?

(I will also check if there are more parameters left uncoverd by the Gradle configuration)

KonstantinSviridov commented 9 years ago

Hi, @getmehrotra

We've added jsonMapperConfiguration and other parameters to the Gradle plugin configuration.

Regards, Konstantin