我正在使用 Apache CXF 构建 Spring Boot 应用程序。在尝试添加 Swagger 时,我得到规范中没有定义的操作!错误,尽管我通过注释指定了 1-2 个操作。 Swagger 的 CXF 配置部分如下:
factory.setFeatures(Collections.singletonList(createSwaggerFeature()));
public Swagger2Feature createSwaggerFeature() {
Swagger2Feature swagger2Feature = new Swagger2Feature();
swagger2Feature.setPrettyPrint(true);
swagger2Feature.setSupportSwaggerUi(true);
swagger2Feature.setScanAllResources(true);
swagger2Feature.setHost("localhost:8080");
swagger2Feature.setBasePath("/cxf/todo_list");
swagger2Feature.setTitle("TodoList Application");
swagger2Feature.setContact("https://www.github/abondar24");
swagger2Feature.setDescription("Another TodoList application with Spring Boot and Swagger");
swagger2Feature.setVersion("1.0.0");
return swagger2Feature;
}
我认为功能设置不正确。我缺少什么? api-docs 的链接如下:http://localhost:8080/cxf/todo_list/api-docs?url=/cxf/todo_list/swagger.json
在 UI 页面上的探索字段中:/cxf/todo_list/swagger.json
最佳答案
我已经解决了这个问题。我忘记将 @Path 注释添加到我的 REST 服务中。完成后,我就 Swagger 开始工作了。我唯一不明白的是 - 如何摆脱默认标签
关于java - Swagger UI 和 CXF 规范中没有定义操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46508257/