Reputation: 11
In my Swagger documentation, for POST requests, it should not show the boolean field in the request body.
I want to ignore the booleanValue
field in the DTO class below:
public class MyDto {
private String stringValue;
@JsonIgnore
private int intValue;
private boolean booleanValue;
}
I have tried using @JsonIgnore
and @JsonIgnoreProperties
, but it is not working.
1. @JsonIgnore
private boolean booleanValue;
2. @JsonIgnoreProperties(value = { "booleanValue"})
public class MyDto {
/* ... */
}
How can I ignore the boolean field in the MyDto
class?
Upvotes: 1
Views: 2112
Reputation: 11
You will need to change dataType from boolean to Boolean, then it will work. Thanks
Upvotes: 1
Reputation: 49
is your boolean field starts with isSomething or hasSomething? if yes, then the @Jsonignore doesn't work on it. you need to change it to "something"
Upvotes: 1
Reputation: 130937
Use @ApiModelProperty
and set the hidden
element to true
:
@ApiModelProperty(hidden = true)
private boolean booleanValue;
Upvotes: 0