Jersey PUT, POST generated endpoints don't recognize the implementing subclass arguments


#1

My generated API endpoints don’t recognize a subclassing argument. I’m using RAML 1.0, Jersey 2.11, and the latest raml-for-jax-rs, more specifically raml-to-jax-rs-cli.

In previous generators, the generated API endpoints (PUT, POST) would expect a POJO entity, but now they expect the interface. This should not be a problem, but when I PUT or POST an implementing entity, the endpoint fails to recognize it and does not call the method.

When I change the expected argument/entity to the instantiable class of the object I send, everything works as expected (obviously this is not a sustainable workflow, as it means modifying all the generated endpoints).

I’d like either a solution to this mapping error or a way to generate the API endpoints with the “old-style” expected entities.


My model has two generated classes, Product being an interface and ProductImpl its implementing class.

@Override
public PutProductsResponse putProducts(String xSessionToken, Product entity) {

-> method will not be called when I PUT a ProductImpl entity. This is unexpected behavior.

@Override
public PutProductsResponse putProducts(String xSessionToken, ProductImpl entity) {

-> method will be called, as usual.


I made a StackOverflow question for this as well, which has some extra details.


#2

Hi @JoseHdez2, I’ll try to get an answer for you. Is this related: https://github.com/mulesoft-labs/raml-for-jax-rs/issues/299?


#3

Hello @jstoiko, yes; it is the same as this question. I posted it as an issue since I haven’t been able to solve it and I think it might be related to the generator. For now, I have been able to work when deleting the interfaces and working with just the entity classes, but that is not feasible for the long term.


#4

Hello again @jstoiko; I’ve posted an issue on the issue tracker for the project, and I’d like to know if there are any possible solutions to my problem. Thanks


#5

No worries. Let’s discuss it there.