W
W
web_dev2014-03-12 14:47:20
Java
web_dev, 2014-03-12 14:47:20

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>

depedency in pom.xml
<dependency>
      <groupId>com.wordnik</groupId>
      <artifactId>swagger-jersey-jaxrs_2.10</artifactId>
      <version>1.3.0</version>
    </dependency>


Well, in the class I added an annotation

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


I do not quite understand what exactly I should enter here (configure).
<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>

And how can I get through to all this?
The project starts in Tomcat

Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question