@ApiImplicitParam不生效
时间: 2024-01-23 10:36:28 浏览: 112
@ApiImplicitParam注解在设置name属性值为参数名称时,会让Swagger在请求时再次封装被描述的参数到请求body中,导致参数值有两个,因此无法正确转换为Long类型。为了解决这个问题,可以使用@ApiParam注解代替@ApiImplicitParam注解,并将它与@PathVariable一起使用,如:@PathVariable @ApiParam(name = "id", value = "用户ID", required = true) Long id。这样既能添加参数说明又不改变参数的请求类型。 [2]
同时使用@ApiParam和@ApiImplicitParam注解时,如果name值一致,那么@ApiImplicitParam注解将会生效,而@ApiParam注解则无效。如果value值不同,那么以value值相同的注解为准。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *3* [关于swagger注解@ApiParam 和 @ApiImplicitParam 的问题](https://blog.csdn.net/yeshenyuexieriji/article/details/121399711)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *2* [使用Swagger2的@ApiImplicitParam注解遇到的坑,导致MethodArgumentTypeMismatchException](https://blog.csdn.net/Monarchess_1234/article/details/128327635)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文