-
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
Showing
2 changed files
with
44 additions
and
0 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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/dnd/accompany/global/config/docs/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,41 @@ | ||
package com.dnd.accompany.global.config.docs; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
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.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
|
||
@Configuration | ||
@Profile({"local", "dev", "prod"}) | ||
public class OpenApiConfig { | ||
|
||
@Bean | ||
public OpenAPI openApi() { | ||
Info info = new Info() | ||
.title("DND API Document"); | ||
|
||
String jwtSchemeName = "Authorization"; | ||
|
||
SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName); | ||
|
||
Components components = new Components() | ||
.addSecuritySchemes(jwtSchemeName, new SecurityScheme() | ||
.name(jwtSchemeName) | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("Bearer") | ||
.bearerFormat("JWT")); | ||
|
||
return new OpenAPI() | ||
.addServersItem(new Server().url("/")) | ||
.components(new Components()) | ||
.addSecurityItem(securityRequirement) | ||
.components(components) | ||
.info(info); | ||
} | ||
} |