Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Archives
Today
Total
관리 메뉴

NOT FOUND

Unable to render this definition Spring boot Swagger error exception handler 본문

spring boot

Unable to render this definition Spring boot Swagger error exception handler

신토불이 2025. 2. 19. 17:13

에러 문구

Unable to render this definition

The provided definition does not specify a valid version field.

Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0).

 

에러 사진

 

에러 원인

우선 저는 @RestControllerAdvice와 @ExceptionHandler 때문이었습니다.

다른 원인일 경우도 있는데

http://localhost:8080/v3/api-docs

해당 URL에 접속했을 때 자신이 설정한 에러가 나온다면 exception handler때문일 확률이 매우 큽니다.

 

우선 예외를 출력해봤습니다.

Handler dispatch failed: java.lang.NoSuchMethodError: 'void org.springframework.web.method.ControllerAdviceBean.<init>(java.lang.Object)'
java.lang.NoSuchMethodError: 'void org.springframework.web.method.ControllerAdviceBean.<init>(java.lang.Object)'

 

에러 해결

springdoc:
  api-docs:
    enabled: true
  swagger-ui:
    path: /swagger-ui.html
  override-with-generic-response: false

.yml 파일에 override-with-generic-response: false 를 추가하면 해결됩니다.

 

해당 속성에 대한 설명입니다. When true, automatically adds @ControllerAdvice responses to all the generated responses.

 

즉 true일 경우 모든 응답에 @ControlerAdvice 응답을 추가하는 속성인 것입니다. 

기본값이 true이기때문에 false로 바꾸어주시면 해결됩니다.