Skip to content

Add support for HandlerTypePredicate in spring-web #1258

Closed
@amiraziz

Description

@amiraziz

Describe the feature

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/...

image

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

I use this versions:

spring-boot-starter-parent => 2.3.12.RELEASE
springdoc-openapi-data-rest & springdoc-openapi-ui => 1.5.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions