[Swagger/error] Unable to interpret the implicit parameter configuration with dataType

강신현·2022년 10월 5일
0
post-thumbnail

문제

Swagger로 간편하게 api를 구현하는 과정에서 아래와 같은 에러가 발생했다.

Unable to interpret the implicit parameter configuration with dataType: , dataTypeClass: class java.lang.Void

원인

Swagger의 @ApiImplicitParam 어노테이션에서 발생하는 에러로, 에러는 java.lang.Void로 implicit parameter를 해석할 수 없다는 뜻이다.

에러가 발생하는 이유는 @ApiImplicitParam 에 정확한 dataTypeClass 를 명시하지 않았기 때문이다.

내부 로직에 의해,
1. dataTypeClass는 값이 주어지지 않는다면, Void.class(디폴트 값)이다.
2. dataTypeClass는 값이 주어진다면, dataType값을 재정의한다.

나의 경우 dataTypeClass을 명시하지 않았기 때문에 디폴트 값인 Void.class 로 들어갔던 것이다.


해결

  • 수정 전
@ApiOperation(value = "유저 Profile 조회")
@ApiImplicitParam(name = "userId", required = true, example = "0")
@GetMapping("/prifile/{userId}")
public ApplicationResponse<UserProfileRes> getProfile(@PathVariable Long userId){
    return userService.getProfile(userId);
}
  • 수정 후
@ApiOperation(value = "유저 Profile 조회")
@ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0")
@GetMapping("/prifile/{userId}")
public ApplicationResponse<UserProfileRes> getProfile(@PathVariable Long userId){
    return userService.getProfile(userId);
}

https://velog.io/@youjung/Swagger-Unable-to-interpret-the-implicit-parameter-configuration-with-dataType

profile
땅콩의 모험 (server)

0개의 댓글