Skip to content

Commit

Permalink
Merge pull request #204 from woowacourse-teams/fix/#176
Browse files Browse the repository at this point in the history
`@LoginMember`가 스웨거 파라미터에 포함되지 않도록 수정. 인증 정보 입력할 수 있도록 수정
  • Loading branch information
Mingyum-Kim authored Aug 4, 2024
2 parents ccf2e0b + ed71602 commit 5cc6520
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions backend/src/main/java/mouda/backend/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package mouda.backend.config;

import org.springdoc.core.utils.SpringDocUtils;
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.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import mouda.backend.config.argumentresolver.LoginMember;

@Configuration
public class SwaggerConfig {

static {
SpringDocUtils.getConfig().addAnnotationsToIgnore(LoginMember.class);
}

@Bean
public OpenAPI openAPI() {
return new OpenAPI().addSecurityItem(
new SecurityRequirement().addList("Bearer Authorization"))
.components(new Components().addSecuritySchemes(
"Bearer Authorization", createBearerTokenScheme()
));
}

private SecurityScheme createBearerTokenScheme() {
return new SecurityScheme().type(SecurityScheme.Type.HTTP)
.bearerFormat("JWT")
.scheme("bearer");
}
}

0 comments on commit 5cc6520

Please sign in to comment.