Jax-rs to raml support multiple schemas for the same method


#1

Hi,

I am using jaxrs-raml maven plugin to generate raml file.

In my case, I have have same url with different methods for post/put , which differs with versioning provided in @produces and @consumes like below

@Produces(application/{compname}-{modulename}.v1+json)
@Consumes(application/{compname}-{modulename}.v1+json)

@Path(employee/update)
@Produces(application/{compname}-update-by-addressid.v1+json)
@Consumes(application/{compname}-{modulename}.v1+json)
Employee updateDetailsByAddressId();

@Path(employee/update)
@Produces(application/{compname}-update-by-stateid.v1+json)
@Consumes(application/{compname}-{modulename}.v1+json)
Employee updateDetailsByStateId();

Where here response schema differs for first two methods , returning addressId in firstcase and stateId in second case.

In the generated raml, type is coming as

Type: application/json where as it should be Type: application/{compname}-{modulename}.v1+json, seems plugin is only detecting as application/json or application/xml,
because of this I don’t see any different response schema’s for the same method, something like below

{
name:
id:
addresses: [
{
type: byAddressId
} ]
}

{
name:
id:
addresses: [
{
type: bystateId
} ]
}

Can anyone help on this?


#2

This is definitely an issue in existing raml->jaxrs. Please file an enchancement request RAML for Jaxrs

Regards,
Pavel


#3

If you dont mind me hijacking the thread a little bit, I would be very interested in the desire to go from code to RAML instead of defining a RAML API that matches your existing API, and migrate towards RAML to JAXRS generating the JAXRS interfaces? I do understand many will already have a hand written existing JAXRS implementation. However, with very little work you can usually quickly match a RAML API to the existing JAXRS implementation, and then migrate towards generating JAXRS with the RAML to JAXRS project (at least for 0.8, 1.0 is in flight). My purpose in asking this is for my own curiosity about the use of code as the single source of truth and generating RAML, as well as if teams feel it is too difficult to define a RAML API that matches their existing implementation of JAXRS (or really any language/framework, so long as it is a REST API implementation). Thanks.