'duplicate boolean value in swagger ui
I have created a Rest API endpoint to create an employee with isAvailable Boolean type as a property of bean class. But in swagger UI it shows duplicate, one available and another one isAvailable. That is very weird, below is the sample.
{
available: true,
"address": {
"city": "string",
"country": "string",
"id": 0,
"postalCode": "string",
"street": "string"
},
"employeeId": 0,
"employeeEmail": "string",
"firstname": "string",
"lastname": "string",
"telephone": "string",
"isAvailable": true
}
I searched on swagger docs but did not find any clue nor in any blog post. I must not be the first one to encounter this problem. How to solve this problem?
Solution 1:[1]
Swagger strips the "is" if a variable is a boolean. Can be fixed by annotating the getter:
@JsonGetter("isAvailable")
public boolean isAvailable() {
return isAvailable;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MevlütÖzdemir |
