How to resuse @ApiImplicitParam?

442 views
Skip to first unread message

Henrik Helmø Larsen

unread,
Sep 17, 2015, 9:52:00 AM9/17/15
to Swagger
I have a RESTful API where I have annotated one of my GET methods with the @ApiImplicitParam.
This is working great - the param shows up in the automatically generated Swagger-UI :-)

My problem is that I have some 100+ endPoints that contain the same params - how can I reuse the @ApiImplicitParam so I only have to define these Params once?

I know that you can use $ref if you make the swagger-file yourself - but I am annotating it inside Java and this needs to be done automatically...

I am able to define Parameters in the Swagger-Object - but how do I refer to these from an @ApiImplicitParam (this would solve half of my problem...) or which annotation should I use instead to refer to the predefined parameters?

Tony Tam

unread,
Sep 17, 2015, 10:44:23 AM9/17/15
to swagger-sw...@googlegroups.com
Hi, are you using jersey?  If so you can annotate class-level params and they will apply to all methods. 
--
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.

Henrik Helmø Larsen

unread,
Sep 17, 2015, 11:33:09 AM9/17/15
to Swagger
Thank you for the quick reply

Yes - I am using Jersey. I have gathered all methods for same endPoint in the same class:

@GET
public Response getX(...)

@PUT
public Response putX(...)

etc...

I am only interested in annotating the @ApiImplicitParams on the @GET method:

@GET
@ApiImplicitParams(values = {@ApiImplicitParam1, @ApiImplicitParam2, etc...}
public Response getX(...)

(Btw. how do you annotate parameters on classLevel? @ApiImplicitParam has @Target(value=METHOD))

Ron Ratovsky

unread,
Sep 21, 2015, 10:54:57 AM9/21/15
to Swagger
Yeah, was going to say I don't think @ApiImplicitParam supports class-level definitions.

Using annotations, you'd have to manually add them all over. You may be able to manipulate the definition programmatically, but... that would be programmatically :)

--
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