swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

allowableValues extends in stead of replaces allowed values

Open jlous opened this issue 5 years ago • 1 comments

Awaiting restored support for @JsonProperty/@JsonValue in enums (#3553), I tried to work around the issue using @Schema and allowableValues, but it turns out this only adds to the set of allowed values, and does not replace the Java names, which my API does not actually support.

Java code:

@Schema(allowableValues = {"num-one", "num-two"})
public enum SomeEnum {
  @JsonProperty("num-one")
  NUMONE,
	
  @JsonProperty("num-two")
  NUMTWO
}

Expected in OpenApi schema: enum: ["num-one", "num-two"] actual: enum: ["NUMONE", "NUMTWO", "num-one", "num-two"]

jlous avatar May 24 '20 09:05 jlous

This is a duplicate of existing issue: https://github.com/swagger-api/swagger-core/issues/2949. The workaround suggested elsewhere is to specify the Schema type as "string", though the implications of this are unclear.

Dholmblad avatar Jun 07 '22 18:06 Dholmblad