Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with new PathMatcher #965

Closed
MatsLP opened this issue Dec 2, 2020 · 1 comment
Closed

Compatibility with new PathMatcher #965

MatsLP opened this issue Dec 2, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@MatsLP
Copy link

MatsLP commented Dec 2, 2020

Hello,

We are facing a problem when we try to use org.springdoc:springdoc-openapi-ui and enable the new PathMatcher in our webmvc application. The new PathMatcher is available for webmvc since spring-boot 2.4.0 and is intended to replace the AntMatcher.

When we add the WebMvcConfigurer that I appended at the end, we get an error that says:

Invalid mapping pattern detected: /**/swagger-ui/**
^
No more pattern data allowed after {*...} or ** pattern element

I think this might be related to an incompatibility that the spring-team mentions here: https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc
Is springdocs compatible with mvc-applications that want to use the new PathPatter, or is this feature planned?

Kind regards and thank you for your work

Additional context

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.method.HandlerTypePredicate;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.util.pattern.PathPatternParser;

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        configurer
                .setPatternParser(new PathPatternParser())
                .addPathPrefix("", HandlerTypePredicate.forAnnotation(RestController.class));
    }
}
@samotoo
Copy link

samotoo commented Dec 23, 2020

Hi,

We are having the same issue here. The PathPatternParser doesn't allow ** to appear in the middle, and will reject such pattern (see spring-projects/spring-boot#21694 for details).

It looks like the code here inserted a ** in the middle of the path pattern.

For reference WebFlux uses the PathPatternParser from its birth, so SwaggerWebFluxConfigurer doesn't insert ** in the middle of the path? Maybe SwaggerWebMvcConfigurer can borrow the implementation from SwaggerWebFluxConfigurer?

And many thanks to the author for bringing OpenAPI v3 to spring boot!

This was referenced Mar 16, 2021
@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants