Skip to content

Commit

Permalink
✨ feat: Swagger token 설정 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunmin0317 committed Feb 28, 2024
1 parent edbc504 commit 26cff16
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
package com.smunity.petition.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.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;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

@Bean
public OpenAPI getOpenApi() {
return new OpenAPI().info(getSwaggerInfo());
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("Copyright (c) 2024 Smunity");

license.setName("{Application}");
return new Info()
.title("Smunity API Document")
.description("Smunity의 API 문서 입니다.")
.description("This is Smunity'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 26cff16

Please sign in to comment.