【问题标题】:Swagger UI and CXF No operations defined in specSwagger UI 和 CXF 规范中没有定义操作
【发布时间】:2017-10-01 00:41:59
【问题描述】:

我正在使用 Apache CXF 构建 Spring Boot 应用程序。在尝试添加招摇时,我得到没有在规范中定义的操作!错误,尽管我通过注释 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

【问题讨论】:

标签: java spring cxf swagger


【解决方案1】:

我已经解决了这个问题。我忘记将@Path 注释添加到我的 REST 服务中。在我这样做之后,它大摇大摆地开始工作。我唯一不明白的 - 如何摆脱默认标签

【讨论】:

【解决方案2】:

我也有同样的问题, 我通过修改控制器模块修复它

在这里,我从 @Controller => 更改为 @RestController 并且成功了。

【讨论】:

    猜你喜欢
    • 2020-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    • 2015-06-12
    • 2019-06-07
    • 2019-02-10
    相关资源
    最近更新 更多