我正在使用swagger-jersey2-jaxrs
生成swagger.json
。这是我的Java代码:
@Path("/example")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiImplicitParams({
@ApiImplicitParam(name = "object", required = true, dataTypeClass = MyObject.class, paramType = "body")
})
@ApiOperation(value = "Return one entity", notes = "Returns one entity at random", response = CommonResponse.class)
public String getStuff(String requestString) {...}
结果是我得到了这个swagger.json
文件:
"parameters": [
{
"in": "body",
"name": "body", // SHOULD BE REMOVED
"required": false,
"schema": {
"type": "string"
}
},
{
"in": "body",
"name": "object", // I ONLY WANT THIS
"required": true,
"schema": {
"$ref": "#/definitions/MyObject"
}
}
]
据我所知String requestString
将默认生成参数名称=“ body”。如何删除?我只希望出现参数name =“ object”。
答案 0 :(得分:1)
通过使用tintColor="green"
中的@ApiParam
注释,您可以隐藏参数。为此,请将字段io.swagger.annotations
设置为hidden
。
true