首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >springdoc swagger没有检测到正确的呼叫url

springdoc swagger没有检测到正确的呼叫url
EN

Stack Overflow用户
提问于 2021-07-31 04:45:33
回答 1查看 612关注 0票数 0

在我的项目中,我需要为所有@RestController bean映射添加前缀。因此,我添加了这个config类:

代码语言:javascript
复制
@Configuration
public class AppConfiguration implements WebMvcConfigurer {

    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        configurer.addPathPrefix("/rest",
                HandlerTypePredicate.forAnnotation(RestController.class));
    }
}

在此之后,我看到swagger没有正确预览默认地址,因此我添加了以下配置键:

代码语言:javascript
复制
springdoc.swagger-ui.path= swagger
springdoc.swagger-ui.url= /rest/api-docs

现在我看到这个页面具有正确的控制器映射,但是当我尝试它时,url再次添加前缀并将地址更改为/rest/rest/...。

代码语言:javascript
复制
@RestController
public class WorkflowController {

    private final WorkflowService workflowService;
    private final Environment environment;


    public WorkflowController(WorkflowService workflowService, Environment environment) {
        this.workflowService = workflowService;
        this.environment = environment;
    }

    @PostMapping(value = "/phoneCharge")
    public GeneralResponse startChargeProcess(@Valid @RequestBody MerchantChargeRequestDto dto, HttpServletRequest request) {
        return workflowService.startChargeProcess(dto, request.getRemoteAddr(), "ChargeProcess");
    }
}

怎么啦?

我使用这个版本

spring-启动-启动器-父=> 2.3.12

springdoc data-rest&springdoc ui => 1.5.9

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-19 06:08:17

这是该版本中的一个错误(不支持HandlerTypePredicate)。

看我的封闭性问题:

https://github.com/springdoc/springdoc-openapi/issues/1258#issuecomment-922325290

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68599162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档