Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
Spring boot Springfox Swagger UI-不使用其他模型隐藏或过滤不同请求的字段_Spring Boot_Rest_Swagger_Swagger Ui_Swagger 2.0 - Fatal编程技术网

Spring boot Springfox Swagger UI-不使用其他模型隐藏或过滤不同请求的字段

Spring boot Springfox Swagger UI-不使用其他模型隐藏或过滤不同请求的字段,spring-boot,rest,swagger,swagger-ui,swagger-2.0,Spring Boot,Rest,Swagger,Swagger Ui,Swagger 2.0,是否可以使用SpringBoot和Springfox Swagger 2.9.2过滤(隐藏)不同请求的特定字段 我得到了模型“流派”: 还有一本“书”,第一本包括: { "id": 0, "genres": [ { "id": 0, "type": "string" } ], "isbn": "string", "title": "string", "author": "string", "publishedYear": "st

是否可以使用SpringBoot和Springfox Swagger 2.9.2过滤(隐藏)不同请求的特定字段

我得到了模型“流派”:

还有一本“书”,第一本包括:

{
  "id": 0,
  "genres": [
    {
      "id": 0,
      "type": "string"
    }
  ],
  "isbn": "string",
  "title": "string",
  "author": "string",
  "publishedYear": "string",
  "price": "string",
  "quantity": 0
}
我想在Swagger UI中显示第一个模型“流派”的所有字段
GET/Genres
但是隐藏
“type”:“string”
用于“Book”模型
POST/books
,因为它不是强制性的,基本上是关于图书类型的重复信息

有没有可能这样做?我不想使用DTO或任何单独的模型来实现这一点,但令我惊讶的是,似乎没有其他选择,因为大摇大摆的开发人员没有留下这种可能性

我试过:

@ApiModelProperty(readOnly = true)
private String type;
以及:

但这没用

@JsonIgnore隐藏了每个请求的字段,这不是我想要的:

@JsonIgnore
private String type;
我看了看,但似乎没有解决办法。 我错过什么了吗?在谷歌上搜索这个问题,我发现很多人多年来都在寻找这个功能:(

@ApiModelProperty(accessMode = ApiModelProperty.AccessMode.READ_ONLY)
private String type;
@JsonIgnore
private String type;