When using API Versioning together with springdoc with swagger-ui enabled and path segments, the URL to load the openapi spec changes from /v3/api-docs (default) to /v3/v1/api-docs (when using ApiVersionConfigurer.usePathSegment(1)). But the swagger-ui still uses the default URL /v3/api-docs to load the openapi spec and fails.
My current workaround is to write a custom version resolver that extends from PathApiVersionResolver to exclude the mentioned URLs from API versioning (as the openapi document anyhow lists the different versions).
So instead of having to write a custom version resolver, it would be great to have an excludePaths() method on the ApiVersionConfigurer that does exactly that:
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
public static final String DEFAULT_VERSION = "v1";
@Override
public void configureApiVersioning(ApiVersionConfigurer configurer) {
configurer
.usePathSegment(1)
.setDefaultVersion(DEFAULT_VERSION)
.addSupportedVersions(DEFAULT_VERSION, "v2")
.excludesPaths("/v3/api-docs*/**","/swagger-ui/**"); // proposed method
}
What do you think?
When using API Versioning together with springdoc with swagger-ui enabled and path segments, the URL to load the openapi spec changes from
/v3/api-docs(default) to/v3/v1/api-docs(when usingApiVersionConfigurer.usePathSegment(1)). But the swagger-ui still uses the default URL/v3/api-docsto load the openapi spec and fails.My current workaround is to write a custom version resolver that extends from
PathApiVersionResolverto exclude the mentioned URLs from API versioning (as the openapi document anyhow lists the different versions).So instead of having to write a custom version resolver, it would be great to have an
excludePaths()method on theApiVersionConfigurerthat does exactly that:What do you think?