-
Notifications
You must be signed in to change notification settings - Fork 0
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 #13 from feature/swagger-config
[Feature] SwaggerConfig μμ±
- Loading branch information
Showing
4 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/main/java/gdsc/sc/bsafe/global/config/ApplicationSecurityConfig.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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/gdsc/sc/bsafe/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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package gdsc.sc.bsafe.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.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpHeaders; | ||
|
||
import static io.swagger.v3.oas.models.security.SecurityScheme.In.HEADER; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
private static final String KEY = "Access Token (Bearer)"; | ||
|
||
@Bean | ||
public OpenAPI openAPI() { | ||
Info info = new Info() | ||
.title("API Document") | ||
.version("v1.0") | ||
.description("API λͺ μΈμμ λλ€."); | ||
|
||
SecurityRequirement securityRequirement = new SecurityRequirement() | ||
.addList(KEY); | ||
|
||
SecurityScheme securityScheme = new SecurityScheme() | ||
.name(HttpHeaders.AUTHORIZATION) | ||
.type(SecurityScheme.Type.HTTP) | ||
.in(HEADER) | ||
.bearerFormat("JWT") | ||
.scheme("Bearer"); | ||
|
||
Components components = new Components().addSecuritySchemes(KEY, securityScheme); | ||
|
||
return new OpenAPI() | ||
.info(info) | ||
.addSecurityItem(securityRequirement) | ||
.components(components); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../global/config/ApplicationAuditAware.java β ...lobal/security/ApplicationAuditAware.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