How to make Swagger core generate openapi.json documentation with a Year-Month field represented as String?
In code I already tried @JsonFormat and @JsonbDateFormat.
Returned entity is correctly represented as String, with correct format, but documentation always is generated as Object.
Environment:
- io.swagger.core.v3.swagger-jaxrs2 2.1.9
- wildfly 21.0.2
- java 11
Here a snippet:
@JsonbDateFormat(value = "uuuu-MM") // or "yyyy-MM", or @JsonFormat(shape = Shape.STRING, pattern = "uuuu-MM")
private YearMonth reference;
Entity return:
{
"reference": "2020-11",
}
Documentation generated:
{
"openapi" : "3.0.1",
...
"components" : {
"schemas" : {
"Entity" : {
"type" : "object",
"properties" : {
"reference" : {
"type" : "object",
"properties" : {
"year" : {
"type" : "integer",
"format" : "int32"
},
"month" : {
"type" : "string",
"enum" : [ "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" ]
},
"monthValue" : {
"type" : "integer",
"format" : "int32"
},
"leapYear" : {
"type" : "boolean"
}
}
}
}
}
}
}
}