-
- Notifications
You must be signed in to change notification settings - Fork 550
Description
Content & configuration
Swagger/OpenAPI definition:
plugins { id 'java' id 'org.springframework.boot' version '3.1.5' id 'io.spring.dependency-management' version '1.1.7' } group = 'org.example' version = '1.0-SNAPSHOT' repositories { mavenCentral() } dependencies { implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation platform('org.junit:junit-bom:5.10.0') testImplementation 'org.junit.jupiter:junit-jupiter' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } test { useJUnitPlatform() }
Swagger-UI configuration options:
SwaggerUI({ // your config options here })
?yourQueryStringConfig
Is your feature request related to a problem?
Yes. Currently, grouping APIs in Swagger UI requires manually creating GroupedOpenApi beans (in SpringDoc) or configuring repetitive Swagger metadata.
This is tedious and error-prone, especially in large projects with many controllers.
Developers often have to maintain multiple group definitions, which adds unnecessary boilerplate and potential for inconsistencies.
Describe the solution you'd like
Problem / Current Issues
Currently, grouping APIs in Swagger UI requires manually creating GroupedOpenApi beans for each group, for example:
@Bean public GroupedOpenApi userApi() { return GroupedOpenApi.builder() .group("User API") .packagesToScan("mini.controller.user") .build(); } @Bean public GroupedOpenApi productApi() { return GroupedOpenApi.builder() .group("Product API") .packagesToScan("mini.controller.product") .build(); }
Adding annotation-based support for automatic grouping (e.g., @APIGroup) is expected to improve the developer experience by reducing boilerplate and making API organization more intuitive.
example.
@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface ApiGroup { String value(); boolean auth() default false; }
@ApiGroup("users") @RestController @RequestMapping("/users") public class UserController { ... }
When this annotation is applied, Swagger UI should automatically create a group named "users" for all endpoints in that controller.
Describe alternatives you've considered
- Manually defining GroupedOpenApi beans for each group.
- Using package-based or path-based grouping.
Both alternatives are repetitive and require extra maintenance whenever new controllers are added.
Additional context
- This feature would significantly improve developer productivity and maintainability.
- Could be implemented as a Spring Boot auto-configuration for SpringDoc/OpenAPI.
- Supports a cleaner, declarative way to organize API documentation without boilerplate.