Skip to content
  • Sponsor springdoc/springdoc-openapi

  • Notifications You must be signed in to change notification settings
  • Fork 529

Compatibility with new PathMatcher #965

Closed
@MatsLP

Description

@MatsLP

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

Activity

samotoo

samotoo commented on Dec 23, 2020

@samotoo

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!

8 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Compatibility with new PathMatcher · Issue #965 · springdoc/springdoc-openapi