-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
댓글 작성 기능 구현 #151
댓글 작성 기능 구현 #151
Changes from 1 commit
5d2755c
ab3cfb1
4b390da
17fcafb
c8f173c
eb7817b
84a9e31
9c7ba51
d14f23a
d7bf9de
c8c4a51
ebc28b9
0e74bdb
db959ef
e2e044e
32239f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.votogether.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.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import io.swagger.v3.oas.models.security.SecurityScheme.In; | ||
import io.swagger.v3.oas.models.security.SecurityScheme.Type; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
import java.util.List; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
@@ -37,9 +42,22 @@ public OpenAPI openAPI() { | |
.version("v1.0.0") | ||
.description("보투게더 API"); | ||
|
||
final SecurityScheme securityScheme = new SecurityScheme() | ||
.type(Type.HTTP) | ||
.in(In.HEADER) | ||
.name("Authorization") | ||
.scheme("bearer") | ||
.bearerFormat("JWT") | ||
.description("Bearer JWT"); | ||
|
||
final SecurityRequirement securityRequirement = new SecurityRequirement() | ||
.addList("bearerAuth"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호 직접 실험까지! 감사합니다 |
||
return new OpenAPI() | ||
.info(info) | ||
.servers(List.of(devServer, prodServer)); | ||
.servers(List.of(devServer, prodServer)) | ||
.components(new Components().addSecuritySchemes("bearerAuth", securityScheme)) | ||
.security(List.of(securityRequirement)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package com.votogether.global.jwt; | ||
|
||
import io.swagger.v3.oas.annotations.Hidden; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Hidden | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Auth { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q
신기한 기능이네요!
swagger에 토큰을 적용해볼 수 있는 코드라고 생각하면 될까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞습니다 :) 해당 기능을 사용하면 Swagger 전역적으로 토큰을 적용할 수 있습니다. 현재는
Bearer
토큰을 설정해두었는데, 설정을 수정하면Basic
토큰도 사용이 가능합니다!