-
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.
- Loading branch information
1 parent
edbc504
commit 26cff16
Showing
1 changed file
with
23 additions
and
4 deletions.
There are no files selected for viewing
27 changes: 23 additions & 4 deletions
27
src/main/java/com/smunity/petition/global/config/SwaggerConfig.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 |
---|---|---|
@@ -1,26 +1,45 @@ | ||
package com.smunity.petition.global.config; | ||
|
||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
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; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public OpenAPI getOpenApi() { | ||
return new OpenAPI().info(getSwaggerInfo()); | ||
Server server = new Server().url("/"); | ||
return new OpenAPI() | ||
.info(getSwaggerInfo()) | ||
.components(authSetting()) | ||
.addServersItem(server) | ||
.addSecurityItem(new SecurityRequirement().addList("access-token")); | ||
} | ||
|
||
private Info getSwaggerInfo() { | ||
License license = new License(); | ||
license.setName("Copyright (c) 2024 Smunity"); | ||
|
||
license.setName("{Application}"); | ||
return new Info() | ||
.title("Smunity API Document") | ||
.description("Smunity의 API 문서 입니다.") | ||
.description("This is Smunity's API document.") | ||
.version("v0.0.1") | ||
.license(license); | ||
} | ||
|
||
private Components authSetting() { | ||
return new Components() | ||
.addSecuritySchemes( | ||
"access-token", | ||
new SecurityScheme() | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT")); | ||
} | ||
} |