【发布时间】:2017-11-25 23:56:41
【问题描述】:
我正在尝试在 SpringBoot (1.5.8) 中将 Swagger (2.6) 与 Jersey (1.5) 一起使用
我对公共 API 的调用工作正常 http://localhost:57116/rest/customer/list
当我加载http://localhost:57116/swagger-ui.html 站点时,它会显示带有许多默认 API 的 Swagger,但它不会显示我的 API。
我尝试关注这个Config Swagger-ui with Jersey,但它仍然没有回来。
这是我的 JerseyConfig
@Configuration
@ApplicationPath("rest")
public class JerseyConfig extends ResourceConfig {
public JerseyConfig()
{
register(CustomerImpl.class);
configureSwagger();
}
public void configureSwagger()
{
this.register(ApiListingResource.class);
this.register(SwaggerSerializers.class);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setTitle("Swagger sample app");
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[]{"http"});
beanConfig.setHost("localhost:57116");
beanConfig.setBasePath("/rest");
beanConfig.setResourcePackage("com.mypackage");
beanConfig.setScan(true);
}
}
这是我的应用类
@SpringBootApplication
@EnableDiscoveryClient
@EnableSwagger2
public class CustomerApplication {...}
这是我的终点
@Component
@Path("customer")
@Api(value = "Customer API")
public class CustomerImpl {
@Path("list")
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "list")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = List.class),
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 403, message = "Forbidden"),
@ApiResponse(code = 404, message = "Not Found"),
@ApiResponse(code = 500, message = "Failure")})
public String[] getList()
{
return new String[]{"IBM", "Microsoft", "Victor"};
}
}
当我使用 Spring RestController 尝试类似的配置时,它工作正常,但在 Jersey 中我看不到我的公共 API。它似乎忽略了我的 Swagger 配置
【问题讨论】:
标签: jersey swagger-ui