Amir Azizkhani
Amir Azizkhani

Reputation: 1804

springdoc swagger not detect correct url for call

in my project, i need to add prefix for all @RestController beans mapping. so i add this config class:

@Configuration
public class AppConfiguration implements WebMvcConfigurer {

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

after that i see swagger not preview correctly with default address, so I add this config keys:

springdoc.swagger-ui.path= swagger
springdoc.swagger-ui.url= /rest/api-docs

now i see this page with correct controller mapping but when i try it, url add prefix again and address change to /rest/rest/...

enter image description here

@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");
    }
}

what is wrong?

I use this versions

spring-boot-starter-parent => 2.3.12.RELEASE

springdoc-openapi-data-rest & springdoc-openapi-ui => 1.5.9

Upvotes: 0

Views: 1103

Answers (1)

Amir Azizkhani
Amir Azizkhani

Reputation: 1804

this a bug in that version (not support for HandlerTypePredicate).

see my closed issue :

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

Upvotes: 1

Related Questions