This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from FinFellows/develop
feat: Swagger 설정 추가 (#27)
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/finfellows/global/config/OpenApiConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.finfellows.global.config; | ||
|
||
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.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Contact; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.info.License; | ||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
|
||
@Configuration | ||
public class OpenApiConfig { | ||
|
||
private final String securitySchemeName = "bearerAuth"; | ||
|
||
@Bean | ||
public OpenAPI openAPI(@Value("OpenAPI") String appVersion) { | ||
Info info = new Info().title("FinFellow API").version(appVersion) | ||
.description("FinFellow 웹 애플리케이션 API입니다.") | ||
.termsOfService("http://swagger.io/terms/") | ||
.contact(new Contact().name("FinFellow").email("[email protected]")) | ||
.license(new License().name("Apache License Version 2.0") | ||
.url("http://www.apache.org/licenses/LICENSE-2.0")); | ||
|
||
return new OpenAPI() | ||
.addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) | ||
.components( | ||
new Components() | ||
.addSecuritySchemes(securitySchemeName, | ||
new SecurityScheme() | ||
.name(securitySchemeName) | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT") | ||
) | ||
) | ||
.info(info); | ||
} | ||
|
||
} |