Host Multiple Swagger endpoints for the same application

2,049 views
Skip to first unread message

dd...@appneta.com

unread,
Jul 15, 2015, 5:15:34 PM7/15/15
to swagger-sw...@googlegroups.com
Hi,

We are planning to use swagger ui to document our REST apis.
One of the problems we are facing currently is that we have multiple versions of the API hosted in different folders/packages. For example /v1, /v2 and /internal which are not public facing. It is possible to host swagger in a fashion such that each swagger endpoint only documents endpoints under a certain folder.
For example 
/v1/swagger  -> Documents all REST endpoints under /v1
/internal/swagger -> Documents all REST endpoints under /internal.

The application is currently using swagger-jersey2-jaxrs_2.10 : 1.3.x

Any help in this regard would be appreciated.

Thanks,
Debojit

P.S : I was trying to use ReflectiveJaxrsScanner to choose the resource packages to scan but that keeps reporting all the REST endpoints in the project rather than the ones under the selected package.

Ron Ratovsky

unread,
Jul 16, 2015, 2:53:37 AM7/16/15
to swagger-sw...@googlegroups.com
Hi Debojit,

Using 1.3.X, it's not possible to separate the calls as you're trying.
1.5.X allows it, although it would require some work.

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

deboj...@gmail.com

unread,
Jul 16, 2015, 11:24:49 AM7/16/15
to swagger-sw...@googlegroups.com
Thanks Ron for your suggestion! I will upgrade to 1.5.X and give it a try. 
Could you point me to any sample/ documentation that explains how to achieve this?

Thanks,
Debojit

Ron Ratovsky

unread,
Jul 16, 2015, 11:26:00 AM7/16/15
to swagger-sw...@googlegroups.com
The upgrade itself or hosting multiple endpoints?

deboj...@gmail.com

unread,
Jul 16, 2015, 11:30:46 AM7/16/15
to swagger-sw...@googlegroups.com
Regarding hosting multiple endpoints

Ron Ratovsky

unread,
Jul 16, 2015, 11:33:47 AM7/16/15
to swagger-sw...@googlegroups.com
No, there's no documentation for it unfortunately.

deboj...@gmail.com

unread,
Jul 16, 2015, 11:42:59 AM7/16/15
to swagger-sw...@googlegroups.com
Thanks, I will try it out myself. 

dd...@appneta.com

unread,
Jul 22, 2015, 4:00:14 PM7/22/15
to Swagger, deboj...@gmail.com
Hi Ron,

I have upgraded to swagger-jersey2-jaxrs:1.5.0 and also downloaded the latest swagger-ui to render the new spec.However, when I try to load the json file, it gets stuck at "fetching resource .." with a js error "Uncaught TypeError: Cannot read property 'parameters' of null" - I have removed all my code to create a simplest json - yet it still fails. The ui is able to render the petstore sample project properly. Could you please help me with this?
 I have attached the json with this.
swagger (2).json

dd...@appneta.com

unread,
Jul 22, 2015, 6:32:46 PM7/22/15
to Swagger, deboj...@gmail.com, dd...@appneta.com
I have also tried porting a the PetStore resource from the samples into my project - event that fails with a separate error  - "Uncaught RangeError: Maximum call stack size exceeded" I am also attaching the json file for this 
petStore.json

Ron Ratovsky

unread,
Jul 26, 2015, 11:38:28 AM7/26/15
to swagger-sw...@googlegroups.com, deboj...@gmail.com, dd...@appneta.com
Looks like you've missed the SwaggerSerializers provider.

Debojit Dhar

unread,
Jul 27, 2015, 10:15:36 AM7/27/15
to Ron Ratovsky, swagger-sw...@googlegroups.com, deboj...@gmail.com
Hi Ron,
Thanks for your response. Following the example here - https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5, I was using package scanning. So, the entry in my web.xml looks like below - and I use bootstrap with BeanConfig - do you think I should be adding the SwaggerSerializers  provider seperately.

      <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>
                io.swagger.jaxrs.listing,
                {your.application.packages}
            </param-value>
        </init-param>

Ron Ratovsky

unread,
Aug 3, 2015, 11:15:03 AM8/3/15
to Debojit Dhar, swagger-sw...@googlegroups.com, deboj...@gmail.com
Sorry for the delay. Since it's been a while, let's see.

Do you still experience the issue?
Can you share the swagger-related dependencies from your pom.xml?

Debojit Dhar

unread,
Aug 3, 2015, 7:55:05 PM8/3/15
to Ron Ratovsky, Debojit Dhar, swagger-sw...@googlegroups.com
Hi Ron,

Actually it worked with your advice. The package scanner along was
having problem. However, when I include the resources separately in my
Application class, it seems to work.

Thanks,
Debojit

Ron Ratovsky

unread,
Aug 3, 2015, 8:15:40 PM8/3/15
to Debojit Dhar, Debojit Dhar, swagger-sw...@googlegroups.com
Great, thanks the update.
Reply all
Reply to author
Forward
0 new messages