好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 maozzs 于 2022-7-22 17:46 编辑
1 maven配置,swagger2点几的版本貌似都可以
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
2 附件下载swagger配置类: ApiJsonObject.java ApiJsonProperty.java MapReaderForApi.java
下载完的java文件,粘贴到项目里
swagger工具类.rar
(2.63 KB, 下载次数: 9)
3 参考DemoController,入参Map前加@ApiJsonProperty注解就可以啦。
@PostMapping(value = "/demo")
@ApiOperation(value = "获取资产", notes = "入参为map,userId必传")
public String valuationValue(@ApiJsonObject(name = "RequestModel", value = {
@ApiJsonProperty(key = "userId", example = "xsy123", description = "用户Id必传", type = "string", required = true),
@ApiJsonProperty(key = "indexs", example = "1,2", description = "指标编号非必传", type = "string", required = false),
@ApiJsonProperty(key = "queryDate", example = "2018-12-24", description = "查询日期非必传", type = "string", required = false) })
@RequestBody Map<String, Object> params) {
System.out.println(String.format("Method[%s], args[%s]", "demo", params.toString()));
return "";
}
4 亲测有效,看效果。原理是实现了swagger的插件接口。对插件接口进行了重写。
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|