Skip to content

Commit

Permalink
[#282] fix: 그룹화를 코드 기반 설정으로 변경 (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoonyworld authored Dec 3, 2024
1 parent 889490f commit 1bc1520
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
20 changes: 20 additions & 0 deletions src/main/java/com/beat/global/swagger/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.swagger.v3.oas.models.servers.Server;

import org.springdoc.core.customizers.OperationCustomizer;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -41,6 +42,25 @@ public OpenAPI openAPI() {
.addSecurityItem(securityRequirement);
}

@Bean
public GroupedOpenApi generalApi() {
return GroupedOpenApi.builder()
.group("general")
.pathsToMatch("/**")
.pathsToExclude("/api/admin/**")
.addOperationCustomizer(customize())
.build();
}

@Bean
public GroupedOpenApi adminApi() {
return GroupedOpenApi.builder()
.group("admin")
.pathsToMatch("/api/admin/**")
.addOperationCustomizer(customize())
.build();
}

@Bean
public OperationCustomizer customize() {
return (operation, handlerMethod) -> {
Expand Down
7 changes: 1 addition & 6 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@ springdoc:
use-fqn: false
default-consumes-media-type: application/json;charset=UTF-8
default-produces-media-type: application/json;charset=UTF-8
group-configs:
- group: admin
paths-to-match: /api/admin/**
- group: general
paths-to-match: /**
paths-to-exclude: /api/admin/**
swagger-ui:
tags-sorter: alpha
operations-sorter: alpha
display-request-duration: true
urls-primary-name: general
7 changes: 1 addition & 6 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@ springdoc:
use-fqn: false
default-consumes-media-type: application/json;charset=UTF-8
default-produces-media-type: application/json;charset=UTF-8
group-configs:
- group: admin
paths-to-match: /api/admin/**
- group: general
paths-to-match: /**
paths-to-exclude: /api/admin/**
swagger-ui:
tags-sorter: alpha
operations-sorter: alpha
display-request-duration: true
urls-primary-name: general

0 comments on commit 1bc1520

Please sign in to comment.