I have the following endpoint
@GetMapping(value = "/mypath/{mychoice}")
public ResponseClass generateEndpoint(
@PathVariable("mychoice") FormatEnum format,
) {
...
and the following enum
annotated with Jackson
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
public enum Format {
AVRO,
ORC,
PARQUET,
PROTOBUF
}
I hoped, @JsonNaming
annotation will tell swagger to display cases in lowercase, but it doesn't
Adding @JsonProperty
to each case also doesn't help.
It also doesn't accept lowercase URL with error
org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'FormatEnum'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam FormatEnum] for value 'avro'; nested exception is java.lang.IllegalArgumentException: No enum constant FormatEnum.avro
Setting
spring.jackson.mapper.ACCEPT_CASE_INSENSITIVE_ENUMS = true
has no effect (and is true
in code).
Looks like it just doesn't use Jackson to deserialize enum!