无法从Swagger + Jersey获得json

Ale*_*row 5 java api rest jersey swagger

我有基于Jersey 1.18.1的RESTful服务,我想通过Swagger显示我的API .
首先,我必须得到JSON.我读了这个指令:Swagger Core Jersey 1.X Project Setup 1.5.Swagger允许设置不同的配置方法,我决定使用自定义的Application子类.我一步一步地做了所有事情,但我不能得到我必须用于swagger-ui的 JSON .

我做了什么:
我的自定义应用程序

@ApplicationPath("api/v1")
public class DiscountsApp extends Application{

public DiscountsApp() {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.2");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("localhost:8002");
    beanConfig.setBasePath("swaggerapi");
    beanConfig.setResourcePackage("alexiuscrow.diploma.endpoints");
    beanConfig.setScan(true);
}

@Override
public Set<Class<?>> getClasses() {
    Set<Class<?>> resources = new HashSet();
    resources.add(ShopsResources.class);
    //...       
    resources.add(com.wordnik.swagger.jaxrs.listing.ApiListingResource.class);
    resources.add(com.wordnik.swagger.jaxrs.listing.SwaggerSerializers.class);
    return resources;
}
}
Run Code Online (Sandbox Code Playgroud)

ShopsResources

@Path("/shops")
@Api(value="/shops", description="Shops")
public class ShopsResources {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "List shops", httpMethod = "GET", 
        notes = "List nearest or locality shops",
        response = Shops.class, responseContainer = "List")
    public String getShops(
            @ApiParam( value = "Radius", required = false)
            @QueryParam("radius") String radiusParam, 
            @ApiParam( value = "Latitude", required = true)
            @QueryParam("lat") String latParam,
            @ApiParam( value = "Longitude", required = true)
            @QueryParam("lng") String lngParam) throws SQLException{
                //The list of Shops objects is serialized to string 
                //using the custom GSON serializer and I know
                //that there is the better method of the solution of this task.
            }
    }
}
Run Code Online (Sandbox Code Playgroud)

来自pom.xml的一些依赖项

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>1.18.1</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-servlet</artifactId>
    <version>1.18.1</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-bundle</artifactId>
    <version>1.18.1</version>
</dependency>
<dependency>
    <groupId>com.wordnik</groupId>
    <artifactId>swagger-jersey-jaxrs</artifactId>
    <version>1.5.1-M2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

在将应用程序部署到Tomcat之后,我尝试获取http:// localhost:8002/swaggerapi,但我没有结果.
我没有找到swagger.json我的应用程序的根目录(/tomcat8/webapps/app).

怎么了?
如何使用我的API获取JSON?

Ale*_*row 3

我没有正确构建 url。

正确的:

http://{主机}:{端口}/{应用程序的上下文根}/{路径@ApplicationPath}/swagger.json

就我而言:http://localhost:8080/app/api/v1/swagger.json

谢谢罗恩。