Is that possible to filter (hide) specific fields for different requests using Spring Boot and Springfox Swagger 2.9.2?
I got model "Genres":
{
"id": 0,
"type": "string"
}
And another one "Book" with the first included:
{
"id": 0,
"genres": [
{
"id": 0,
"type": "string"
}
],
"isbn": "string",
"title": "string",
"author": "string",
"publishedYear": "string",
"price": "string",
"quantity": 0
}
I want to show all fields for the first model "Genres" in Swagger-UI GET /genres
but hide "type": "string"
for "Book" model POST /books
since it's not mandatory and basically duplicate info about book genre.
Is there any possibility to do that? I don't want to use DTO or any separate models to do this, but to my astonishment, it's seems there is no other choice since Swagger developers didn't leave such a possibility.
I tried:
@ApiModelProperty(readOnly = true)
private String type;
And:
@ApiModelProperty(accessMode = ApiModelProperty.AccessMode.READ_ONLY)
private String type;
But it didn't help.
@JsonIgnore hides field for every request which is not what I'm looking for:
@JsonIgnore
private String type;
I viewed this and this, but it seems like there is no solution. Do I miss something? Googling this issue I found a lot of people who look for this feature for years :(