Skip to content

GroupedOpenApi not working in Spring MVC #841

@onlykalu

Description

@onlykalu

My Application is Sping MVC not boot.

I'm using springdoc-openapi-ui 1.4.4

also, I added the following imports to one of my @configuration class;

@Import({ 
	org.springdoc.core.SpringDocConfigProperties.class, org.springdoc.core.SpringDocConfiguration.class, 
	org.springdoc.webmvc.core.SpringDocWebMvcConfiguration.class,
	org.springdoc.webmvc.core.MultipleOpenApiSupportConfiguration.class,
	org.springdoc.core.SwaggerUiConfigProperties.class, org.springdoc.core.SwaggerUiOAuthProperties.class,
	org.springdoc.webmvc.ui.SwaggerConfig.class, org.springdoc.core.CacheOrGroupedOpenApiCondition.class,
	org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.class })

and implement the beans as below

@Bean
public GroupedOpenApi publicApi() {
    return GroupedOpenApi.builder()
            .group("user")
            .pathsToExclude("/api/v2/**", "/v2/**")
            .pathsToMatch("/api/v1/**", "/v1/**")
            .build();
}
@Bean
public GroupedOpenApi adminApi() {
    return GroupedOpenApi.builder()
            .group("admin")
            .pathsToExclude("/api/v1/**", "/v1/**")
            .pathsToMatch("/api/v2/**", "/v2/**")
            .build();
}

@Bean
public OpenAPI customOpenAPI() {
    return new OpenAPI()
        .components(new Components())
        .info(new Info()
        	.title("titleI")
        	.version("1.0.0"));
}

But when I try http://localhost:8080/MyApp/v3/api-docs/user

gives me 404.

but I get all the APIs listed in http://localhost:8080/MyApp/v3/api-docs

Also it comes in http://www.onlykalu.com:81/MyApp/swagger-ui/index.html?configUrl=/MyApp/v3/api-docs/swagger-config

also without definition drop down.

if I add

springdoc.group-configs[0].group=user
springdoc.group-configs[1].group=admin

to application.properties then I get

image

Do I need to import any other class to get group functionality work?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions