Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Swagger文档中隐藏控制器参数_Java_Jersey_Swagger - Fatal编程技术网

Java 在Swagger文档中隐藏控制器参数

Java 在Swagger文档中隐藏控制器参数,java,jersey,swagger,Java,Jersey,Swagger,我正在使用swagger-jersey2-jaxrs生成swagger.json。这是我的java代码: @Path("/example") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ApiImplicitParams({ @ApiImplicitParam(name = "object", required = true, dataTypeClass =

我正在使用
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”。

通过使用
@ApiParam
注释从
io.swagger.annotations
可以隐藏参数。为此,请将字段
hidden
设置为
true

...
public String getStuff(
    @ApiParam(hidden = true) String requestString) {...}