我正在使用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,默认情况下会生成参数 name="body"。我怎样才能删除它?我只希望出现我的参数 name="object"。
1 回答
慕森卡
TA贡献1806条经验 获得超8个赞
通过使用@ApiParam注释,io.swagger.annotations您可以隐藏参数。为此,请将字段设置hidden为true。
...
public String getStuff(
@ApiParam(hidden = true) String requestString) {...}
添加回答
举报
0/150
提交
取消