Answer the question
In order to leave comments, you need to log in
Why can't I embed Swagger in a Spring+Jersey RESTful project?
Hello, I'm trying to attach to a project with (Jersey RESTful) Swagger to document a REST API.
There is a manual, there are also a few other examples, but I'm not very good at configuring something.
Java-JAXRS-Quickstart
I will briefly describe what I did and ask for hints, what did I do wrong or what have I not done yet?!
web.xml
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mypackage;com.wordnik.swagger.jersey.listing</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JerseyJaxrsConfig</servlet-name>
<servlet-class>com.wordnik.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>
<init-param>
<param-name>api.version</param-name>
<param-value>1.0.0</param-value>
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>http://localhost:8002/api</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey-jaxrs_2.10</artifactId>
<version>1.3.0</version>
</dependency>
import javax.ws.rs.Path;
import org.springframework.stereotype.Component;
import com.wordnik.swagger.annotations.Api;
@Component
@Path("service/part")
@Api(value = "service/part", description = "Operations about .....")
public class PartServiceController {
......
<init-param>
<param-name>api.version</param-name>
<param-value>1.0.0</param-value>
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>http://localhost:8002/api</param-value>
</init-param>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question