注解:
@ApiImplicitParams
@ApiImplicitParam
name="需注解的API输入参数",
value="接收参数的意义描述",
paramType="参数存放位置",
dataType="参数类型,可传基本类型、类、泛型类等",
required="输入参数是否必传"
其它属性暂时忽略,具体可查看官网等资源。
敲重点:属性“dataType”基本类型、类按照正常来赋值,自定义泛型类应该按照如下格式来赋值:
例如:dataType = "demo«ArrayList«demo1»»",重点是符号“«»”。
以下摘自swagger2源码(各位看官请自行体会):
fieldName | typeName | qualifiedTypeName |
genericByteArray | GenericType«Array«byte»» | springfox.documentation.schema.GenericType<byte[]> |
genericCategoryArray | GenericType«Array«Category»» | springfox.documentation.schema.GenericType<springfox.documentation.schema.Category[]> |
示例:
@ApiImplicitParams(value = {@ApiImplicitParam(name = "input", value = "接收参数的意义描述", paramType = "body", dataType = "demo«ArrayList«demo1»»", required = true), @ApiImplicitParam(name = "index", value = "接收参数的意义描述", paramType = "query", dataType = "String", required = true)})
效果图:
原文地址:https://blog.csdn.net/segmentliuxijun/article/details/81676989