Using @Schema(allowableValues=) for enum param using openapi in spring boot

My API has a enum field in request body. When I generate swagger UI, its showing enum with allowed value as enum names. Instead of enum names, I need to set it to enum values. For that I used @Schema(allowableValues=). This lead to a list with both values and names in swagger UI. Can I set this to values only in swagger?

My enum example :

 public enum Days{
  MON("Monday"),
  SUN("Sunday")
}

Current swagger field looks like :

day string Enum: [ MON, SUN ]

I want it has :

day string Enum: [ Monday, Sunday]

When I add @Schema(allowableValues={"Monday", "Sunday") to the enum field, Swagger becomes:

day string Enum: [ MON, SUN, Monday, Sunday]

Any solution is appreciated.

enter image description here


Solution 1:

use

@Schema(type = "string", allowableValues = { "Monday", "Sunday" })