My specification says that the dates must be in format dd-MM-yyyy
. But default example value in Swagger does have different format (yyyy-MM-dd
).
What I would like the json to be:
{
"SOME_DATE": "22-08-2023"
}
What actually is in json:
{
"SOME_DATE": "2023-08-22"
}
My implementation looks like this :
@JsonProperty(value = "SOME_DATE")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
@ApiModelProperty(required = true, example = "22-08-2023")
@Schema(name = "SOME_DATE", format = "dd-MM-yyyy", example = "22-08-2023")
private LocalDate someDate = null;
but somehow swagger always shows the someDate
in default value in normal form.. When I send example request via swagger-ui it fails (which is correct behavior as of @JsonFormat
)...
Neither the @ApiModelProperty
nor the @Schema
have any positive effect on the format.
edit1: the swagger definition
{
"openapi": "3.0.1",
...
"SOME_DATE": {
"pattern": "dd-MM-yyyy",
"type": "string",
"format": "date",
"example": "2023-08-22"
},
...
}