Skip to content

Commit

Permalink
Merge pull request #57 from BOOK-TALK/#56-add-swagger-header
Browse files Browse the repository at this point in the history
#56 add swagger header
  • Loading branch information
chanwoo7 authored Aug 16, 2024
2 parents f369838 + 49f5357 commit e57813e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ dependencies {
// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

// modelmapper
implementation 'org.modelmapper:modelmapper:3.1.0'

Expand Down
25 changes: 24 additions & 1 deletion src/main/java/com/book/backend/global/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
package com.book.backend.global;

import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;

@OpenAPIDefinition(info = @Info(title = "북토크 서버 API", description = "설명", version = "1.0")) // 상단 제목 커스텀
@Configuration
public class SwaggerConfig { }
public class SwaggerConfig {

@Bean
public OpenAPI api() {
SecurityScheme apiKey = new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.in(SecurityScheme.In.HEADER)
.name("Authorization")
.scheme("bearer")
.bearerFormat("JWT");

SecurityRequirement securityRequirement = new SecurityRequirement()
.addList("Bearer Token");

return new OpenAPI()
.components(new Components().addSecuritySchemes("Bearer Token", apiKey))
.addSecurityItem(securityRequirement);
}
}

0 comments on commit e57813e

Please sign in to comment.