-
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.
- Loading branch information
1 parent
955dea8
commit 18c69b2
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/com/kakaoteck/golagola/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,4 +1,48 @@ | ||
package com.kakaoteck.golagola.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#/ | ||
@Bean | ||
public OpenAPI getOpenApi() { | ||
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("{Application}"); | ||
|
||
return new Info() | ||
.title("GolaGola API Document") | ||
.description("This is GolaGola'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")); | ||
} | ||
} |