@ApiModelProperty not respected within EJB module

285 views
Skip to first unread message

Jussi Juvonen

unread,
Mar 11, 2014, 6:31:55 AM3/11/14
to swagger-sw...@googlegroups.com
Hi and thanks for the great project,

Having an issue with @ApiModelProperty, when my models are defined within EJB module (My project setup is equivalent to https://github.com/wildfly/quickstart/tree/master/ejb-in-ear). If I move the model class into Web module, stuff defined in the annotation show up fine in the API definitions. Any idea how get the annotations working from model classes within EJB module? Or any good suggestions for a work around (excluding the moving of models to web module)?

BR,
-Jussi

Ron

unread,
Mar 11, 2014, 6:41:37 AM3/11/14
to swagger-sw...@googlegroups.com
When moving them between the projects, did you also move their packages?
Also, which JAX-RS implementation do you use?


--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jussi Juvonen

unread,
Mar 11, 2014, 8:19:41 AM3/11/14
to swagger-sw...@googlegroups.com
For testing purposes I just created a model class to each module, for testing I did this (also tried wise-versa just in case):

@GET @ApiOperation(value = "Returns xxx", notes = "Notes", response = TestClassInEjb.class)

@Path("/test")

public void test(TestClass tc){}

TestClass being in web module, and TestClassEjb in EJB module.

I use RestEasy (that bundles with Wildfly 8). 

-J
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron

unread,
Mar 11, 2014, 8:24:47 AM3/11/14
to swagger-sw...@googlegroups.com
That's okay, but I actually asked about Java package of the model.

Can you possibly produce a sample project to show the issue? I could probably find the solution based on that.


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jussi Juvonen

unread,
Mar 11, 2014, 9:36:47 AM3/11/14
to swagger-sw...@googlegroups.com
Hi,

Constructed a simple project to reproduce.

-J

tiistai, 11. maaliskuuta 2014 14.24.47 UTC+2 Ron R kirjoitti:
That's okay, but I actually asked about Java package of the model.

Can you possibly produce a sample project to show the issue? I could probably find the solution based on that.
On Tue, Mar 11, 2014 at 2:19 PM, Jussi Juvonen <juss...@gmail.com> wrote:
For testing purposes I just created a model class to each module, for testing I did this (also tried wise-versa just in case):

@GET @ApiOperation(value = "Returns xxx", notes = "Notes", response = TestClassInEjb.class)

@Path("/test")

public void test(TestClass tc){}

TestClass being in web module, and TestClassEjb in EJB module.

I use RestEasy (that bundles with Wildfly 8). 

-J

tiistai, 11. maaliskuuta 2014 12.41.37 UTC+2 Ron R kirjoitti:
When moving them between the projects, did you also move their packages?
Also, which JAX-RS implementation do you use?
On Tue, Mar 11, 2014 at 12:31 PM, Jussi Juvonen <juss...@gmail.com> wrote:
Hi and thanks for the great project,

Having an issue with @ApiModelProperty, when my models are defined within EJB module (My project setup is equivalent to https://github.com/wildfly/quickstart/tree/master/ejb-in-ear). If I move the model class into Web module, stuff defined in the annotation show up fine in the API definitions. Any idea how get the annotations working from model classes within EJB module? Or any good suggestions for a work around (excluding the moving of models to web module)?

BR,
-Jussi

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
mockproject.zip

Jussi Juvonen

unread,
Mar 11, 2014, 9:43:23 AM3/11/14
to swagger-sw...@googlegroups.com
This is what it produces:

"models":{"TestClass":{"id":"TestClass","description":"Model in web","properties":{"i":{"type":"integer","format":"int32","description":"testting"}}},"EjbModel":{"id":"EjbModel","properties":{"i":{"type":"integer","format":"int32"}}}}}

So from the EjbModel the descriptions are missing.

-J

Ron

unread,
Mar 11, 2014, 9:46:42 AM3/11/14
to swagger-sw...@googlegroups.com
Wait, the problem is that the descriptions are missing or the model as a whole?


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jussi Juvonen

unread,
Mar 11, 2014, 9:57:09 AM3/11/14
to swagger-sw...@googlegroups.com
Descriptions are missing, model shows up fine.

-J

Jussi Juvonen

unread,
Mar 12, 2014, 5:04:28 AM3/12/14
to swagger-sw...@googlegroups.com
Any ideas?

-J

Ron

unread,
Mar 12, 2014, 5:19:01 AM3/12/14
to swagger-sw...@googlegroups.com
Still looking into it.


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

tony tam

unread,
Mar 12, 2014, 2:49:21 PM3/12/14
to swagger-sw...@googlegroups.com
Hi guys, I just added a test to try to reproduce this:


Unfortunately I was not able to.  My guess is that there's some bug in swagger-core with the order at which the properties & methods are scanned.  As a test, could you please add the annotation on the public getter for the property as well?  And we should probably take this issue to github:

Jussi Juvonen

unread,
Mar 13, 2014, 2:43:56 AM3/13/14
to swagger-sw...@googlegroups.com
Hi,

Thanks guys. I tried the the annotation over the public getter also. Didn't have any effect. 

For some reason it just seems to make a difference where the model is located in the project. I don't know exactly how the Swagger does it's annotation scanning from the models (not too familiar with Scala) and could it be possible to debug this some how with the runtime environment? 

-J

Ron

unread,
Mar 13, 2014, 4:59:08 AM3/13/14
to swagger-sw...@googlegroups.com
Jussi,

As Tony mentioned, this seems more like a bug than a configuration issue, and as such, we would appreciate it if you could open a bug about it on swagger-core.

BR,
Ron


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Message has been deleted

Pere Abelló

unread,
Mar 13, 2014, 5:34:14 AM3/13/14
to swagger-sw...@googlegroups.com
I have the same problem.
Could you public the link to the bug here, when it would be opened?

Pere

Jussi Juvonen

unread,
Mar 13, 2014, 7:50:27 AM3/13/14
to swagger-sw...@googlegroups.com
Hi,

Here's the link:
https://github.com/wordnik/swagger-core/issues/485

Thanks guys. Looking forward to the fix, if I can somehow help to speed up the patching, please let me know.

-J

Jussi Juvonen

unread,
Mar 18, 2014, 4:07:21 AM3/18/14
to swagger-sw...@googlegroups.com
We got the issue solved by changing the project configuration. The EJB module scope in web module POM needs to be "compile". Otherwise while Checking the annotations Swagger will receive a proxy instead of the annotation interface and it fails to do the match case for getting the values. Working project attached.
mockproject 2.zip

elisid

unread,
Jun 4, 2014, 1:14:58 PM6/4/14
to swagger-sw...@googlegroups.com

If you put an ejb in the ejb module with a method that returns an instance of "model.EjbModel" and calls the method from the web module, you will produce a ClassCastException since the class of the returned object (from the dependency in the ear) and the expected class (from the "compile" dependency in the war) will come from different places.

I.e. with this solution you cant put any ejb:s in the ejb module...

Is it possible to reopen the bug on GitHub?

Tobias Lehr

unread,
May 22, 2015, 3:16:21 AM5/22/15
to swagger-sw...@googlegroups.com
any updates? I am still facing the same problem.

Ron Ratovsky

unread,
May 26, 2015, 2:57:40 PM5/26/15
to swagger-sw...@googlegroups.com
You can follow this issue and check the last comment. If you can help out, that would be great - https://github.com/swagger-api/swagger-core/issues/485.

On Fri, May 22, 2015 at 3:16 AM, Tobias Lehr <tol...@gmail.com> wrote:
any updates? I am still facing the same problem.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-----------------------------------------
http://swagger.io
https://twitter.com/SwaggerApi
-----------------------------------------
Reply all
Reply to author
Forward
0 new messages