swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.38k stars 2.17k forks source link

Enum field and `allowableValues` constraint #2949

Open gtors opened 6 years ago

gtors commented 6 years ago

Description: The allowableValues parameter not restricts enum values:

enum MyEnum {
    A, B, C
}
// groovy
@Schema(allowableValues=['A' , 'B'])
MyEnum field

Expected behavior:

allowableValues will restrict enum values in SwaggerUI to A, B

Actual behavior:

allowableValues extends enum values in SwaggerUI to A, B, C, A, B

io.swagger.core.v3:swagger-core:2.0.0
io.swagger.core.v3:swagger-annotations:2.0.0
io.swagger.core.v3:swagger-annotations:2.0.0
io.swagger.core.v3:swagger-jaxrs2:2.0.0
io.swagger.core.v3:swagger-integration:2.0.0
guredd commented 4 years ago

@gtors btw, adding @Schema(type="string", allowableValues=['A' , 'B']) fixes this while it is still not obvious.

RInverid commented 5 months ago

You can also @Hidden the default values