Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n
从springboot 1.4.5 升级到springboot 2.7.18 后出现一下问题
遇到这个还不知道哪里出问题,访问 http://localhost:20002/swagger-ui/index.html 出现了
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).
然后用于有几十个controller,只能一个个controller 去配置 .apis(RequestHandlerSelectors.basePackage("com.zhianchen.xxxx.controller.xxx"))
然后发现某个controller中有 @ApiImplicitParam 和 @RequestParam 里面参数不一致,最后 swagger 报错提示了
@RequestMapping(value = "/import", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ApiOperation(value = "导入") @ApiImplicitParams({ @ApiImplicitParam(name = "file", value = "文件", required = true,dataTypeClass =MultipartFile.class ), @ApiImplicitParam(name = "organId", value = "机构id", required = true,dataTypeClass =Long.class ), //todo organId和checkOrganId 不一致 }) public ResponseBody<String> import(@RequestBody @RequestParam(value = "file") MultipartFile file, @RequestParam(value = "checkOrganId") Long checkOrganId) throws Exception {
@ApiImplicitParam 只是swagger 提示作用而已,实际上要改成 @RequestParam 为准,以下是修改后的
@RequestMapping(value = "/import", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ApiOperation(value = "导入") @ApiImplicitParams({ @ApiImplicitParam(name = "file", value = "文件", required = true,dataTypeClass =MultipartFile.class ), @ApiImplicitParam(name = "checkOrganId", value = "机构id", required = true,dataTypeClass =Long.class ), //todo organId和checkOrganId 不一致 }) public ResponseBody<String> import(@RequestBody @RequestParam(value = "file") MultipartFile file, @RequestParam(value = "checkOrganId") Long checkOrganId) throws Exception {
浙公网安备 33010602011771号