I am trying to use swagger in order to document my Rest APIs. I am developing a Tomcat/Spring server and the rest apis are developed using Jersey.
I following swagger guide and added the required data to my web.xml:
<servlet>
<servlet-name>resources</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.wordnik.swagger.jersey.listing;app.servlet.resources.jersey;org.codehaus.jackson.jaxrs</param-value>
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>http://localhost:8080/main/resources/</param-value>
</init-param>
<init-param>
<param-name>api.version</param-name>
<param-value>1</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
http://:8080/main/resources/api-docs returns the following:
{"apiVersion":"0.0","swaggerVersion":"1.2"}
Any idea what i am mising here?
Try to add the following to your "web.xml" (make sure you define the appropriate
servlet-class
locations):and make sure you have "Bootstrap", "ApiOriginFilter", "ApiListingResource" and also "ApiListingResourceJSON" (which extends ApiListing). See in the following examples of these files:
Bootstrap:
ApiOriginFilter:
ApiListingResource:
ApiListingResourceJSON:
This should be it... Swagger is very nice, and once you have it set up it "just works", but to set it up one needs to do some gymnastics still.
HTH.