Skip to content

Commit

Permalink
SCRUM-50 feat: Swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
yeopyeop-82 committed Aug 12, 2024
1 parent 955dea8 commit 18c69b2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/main/java/com/kakaoteck/golagola/config/SwaggerConfig.java
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"));
}
}

0 comments on commit 18c69b2

Please sign in to comment.