-
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.
Browse files
Browse the repository at this point in the history
docs: 스웨거 설정 완료
- Loading branch information
Showing
3 changed files
with
65 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
52 changes: 52 additions & 0 deletions
52
src/main/java/com/hackathon/TimeLapse/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,52 @@ | ||
package com.hackathon.TimeLapse.config; | ||
|
||
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.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; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
// url : http://localhost:8080/swagger-ui/index.html#/ | ||
private static final String SECURITY_SCHEME_NAME = "bearerAuth"; | ||
|
||
@Bean | ||
public OpenAPI api() { | ||
Server server = new Server().url("/"); | ||
|
||
return new OpenAPI() | ||
.addSecurityItem(new SecurityRequirement().addList(SECURITY_SCHEME_NAME)) | ||
.components(authSetting()) | ||
.info(getSwaggerInfo()) | ||
.addServersItem(server); | ||
} | ||
|
||
private Info getSwaggerInfo() { | ||
License license = new License(); | ||
license.setName("{Application}"); | ||
|
||
return new Info() | ||
.title("TimeLapse API Document") | ||
.description("TimeLapse의 API 문서 입니다.") | ||
.version("v1.0") | ||
.license(license); | ||
} | ||
|
||
private Components authSetting() { | ||
|
||
return new Components() | ||
.addSecuritySchemes(SECURITY_SCHEME_NAME, | ||
new SecurityScheme() | ||
.name(SECURITY_SCHEME_NAME) | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT")); | ||
} | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
src/main/java/com/hackathon/TimeLapse/test/TestController.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