Skip to content

Commit

Permalink
[Fix] Config 수정 (#46)
Browse files Browse the repository at this point in the history
* fix: 게시물 api url 대응 (#45)

* fix: swagger config (#44)
  • Loading branch information
yongbin97 authored Oct 3, 2024
1 parent 71c8707 commit e1d5d3f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ dependencies {
implementation 'org.springframework.ai:spring-ai-vertex-ai-gemini-spring-boot-starter:1.0.0-SNAPSHOT'

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

implementation group: 'org.json', name: 'json', version: '20090211'
implementation group: 'org.json', name: 'json', version: '20231013'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.requestMatchers("/exception/**").permitAll()
.requestMatchers("/swagger-ui/**").permitAll()
.requestMatchers("/api-docs/**").permitAll()
.requestMatchers(HttpMethod.POST, "/post").permitAll()
.requestMatchers(HttpMethod.GET, "/post/*").permitAll()
.requestMatchers(HttpMethod.PATCH, "/post/*/summary").permitAll()
.requestMatchers(HttpMethod.POST, "/posts").permitAll()
.requestMatchers(HttpMethod.GET, "/posts/*").permitAll()
.requestMatchers(HttpMethod.PATCH, "/posts/*/summary").permitAll()
.anyRequest().authenticated()
)
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/project/backend/common/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SwaggerConfig {
public class SwaggerConfig implements WebMvcConfigurer {

private static final String BEARER_TOKEN_PREFIX = "Bearer";

Expand Down Expand Up @@ -45,4 +47,13 @@ private Info apiInfo() {
.description("스위프 6기 5팀 API") // API에 대한 설명
.version("1.0.0"); // API의 버전
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");

registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
6 changes: 3 additions & 3 deletions src/main/java/project/backend/security/jwt/JwtFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ private void setErrorResponse(HttpServletResponse response) throws IOException {

private static boolean isRequestSummaryURI(HttpServletRequest request) {
// 요약하기
if (request.getRequestURI().equals("/post") && request.getMethod()
.equals(HttpMethod.POST.name())) {
if (request.getRequestURI().equals("/posts") && request.getMethod()
.equals(HttpMethod.POST.name())) {
return true;
}
// 재요약하기
if (request.getRequestURI().matches("/post/[0-9]+/summary") && request.getMethod().equals(
if (request.getRequestURI().matches("/posts/[0-9]+/summary") && request.getMethod().equals(
HttpMethod.PATCH.name())) {
return true;
}
Expand Down

0 comments on commit e1d5d3f

Please sign in to comment.