前言
遇到报错:Cannot invoke "springfox.documentation.service.ParameterType.getIn()" because the return value of "springfox.documentation.service.RequestParameter.getIn()" is null
怎么解决?
一、报错分析
经过跋山涉水最后定位到报错代码片段:
@PostMapping("/queryOneTimeRewardPunishDeatail")
@ApiOperation(value = "查询一次性奖惩详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "rewardPunishmentId", value = "一次性奖惩编号", required = true),
@ApiImplicitParam(name = "pageNum", value = "当前页码", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页数量", required = true)
})
public ResponseUtil<OneTimeRewardPunishDto> queryOneTimeRewardPunishDeatail(@RequestBody OneTimeRewardPunishParam oneTimeRewardPunishParam) {
省略.....
}
其实报错的原因很简单,那就是使用swagger的@ApiImplicitParams注解描述了不存在的参数,导致报"springfox.documentation.service.RequestParameter.getIn()" is null
的错,只需要修改正确的参数描述就好
二、解决办法
一般可以去看看近期代码修改,哪些修改了controller层的代码,看看是不是参数改了,没修改swagger注解的参数描述,如果发现都正常那就看看别的修改地方哪些使用swagger注解不规范。
修改代码
@PostMapping("/queryOneTimeRewardPunishDeatail")
@ApiOperation(value = "查询一次性奖惩详情")
@ApiImplicitParam(name = "oneTimeRewardPunishParam", value = "一次性奖惩参数", dataTypeClass = OneTimeRewardPunishParam.class, required = true)
public ResponseUtil<OneTimeRewardPunishDto> queryOneTimeRewardPunishDeatail(@RequestBody OneTimeRewardPunishParam oneTimeRewardPunishParam) {
省略.....
}
总结
- 本文简单讲述了报错:
Cannot invoke "springfox.documentation.service.ParameterType.getIn()" because the return value of "springfox.documentation.service.RequestParameter.getIn()" is null
的原因以及解决办法。 - 欢迎大家提出建议以及批评,有任何问题可以私信。