Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #28 from FinFellows/develop
Browse files Browse the repository at this point in the history
feat: Swagger 설정 추가 (#27)
  • Loading branch information
sejineer authored Jan 2, 2024
2 parents e98ccf0 + fe2f501 commit dcc63d0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ dependencies {
runtimeOnly 'com.mysql:mysql-connector-j'

//Swagger, RestDocs
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.1.0'
testImplementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-api', version: '2.1.0'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.3.0'
testImplementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-api', version: '2.3.0'

//jwt
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5'
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/com/finfellows/global/config/OpenApiConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.finfellows.global.config;

import org.springframework.beans.factory.annotation.Value;
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.Contact;
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;

@Configuration
public class OpenApiConfig {

private final String securitySchemeName = "bearerAuth";

@Bean
public OpenAPI openAPI(@Value("OpenAPI") String appVersion) {
Info info = new Info().title("FinFellow API").version(appVersion)
.description("FinFellow 웹 애플리케이션 API입니다.")
.termsOfService("http://swagger.io/terms/")
.contact(new Contact().name("FinFellow").email("[email protected]"))
.license(new License().name("Apache License Version 2.0")
.url("http://www.apache.org/licenses/LICENSE-2.0"));

return new OpenAPI()
.addSecurityItem(new SecurityRequirement().addList(securitySchemeName))
.components(
new Components()
.addSecuritySchemes(securitySchemeName,
new SecurityScheme()
.name(securitySchemeName)
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")
)
)
.info(info);
}

}

0 comments on commit dcc63d0

Please sign in to comment.