Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WALWAL-96] SwaggerConfig 작성 #14

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ dependencies {
// Actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
compileOnly 'org.projectlombok:lombok'

runtimeOnly 'com.h2database:h2'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.depromeet.stonebed.global.config;

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;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;

@Configuration
public class SwaggerConfig {
private static final String PACKAGES_TO_SCAN = "com.depromeet.stonebed";

@Value("${api.version}")
private String apiVersion;

// OpenAPI Bean 설정
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(new Info()
.title("WalWal 프로젝트 API 문서화")
.version(apiVersion)
.description("WalWal 프로젝트의 Swagger UI 화면입니다."));
}

// GroupedOpenApi Bean 설정
@Bean
public GroupedOpenApi groupedOpenApi() {
return GroupedOpenApi.builder().group("WalWal API")
.packagesToScan(PACKAGES_TO_SCAN)
.build();
}
}
18 changes: 18 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,21 @@ management:
endpoint:
health:
enabled: true

springdoc:
api-docs:
path: /api-docs
groups:
enabled: true
swagger-ui:
enabled: true
groups-order: ASC
tags-sorter: alpha
operations-sorter: alpha
display-request-duration: true
doc-expansion: none
cache:
disabled: true

api:
version: "0.0.1"
Loading