Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AllowableValues for @ApiParam is not honored by Swagger when request parameter is Collection Array #3321

Closed
SarveshSharma06 opened this issue May 28, 2020 · 1 comment
Labels
Milestone

Comments

@SarveshSharma06
Copy link

SarveshSharma06 commented May 28, 2020

I am working with springfox version 2.9.2

In my spring boot application, I have a RestController with request parameter like:

@ApiParam(allowableValues="one, two, three")
            @RequestParam(name = "expand", required = false) Set<NumberEnum> numbers

I have an Enum class NumberEnum with values {one, two, three, four}

On swagger am expecting to see: "Available values: one, two, three" Instead I see all the 4 enum values.
Here's how my swagger json looks like:

{
            "name": "numbers",
            "in": "query",
            "description": "some desc",
            "required": false,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "one",
                "two",
                "three",
                "four"
              ]
            },
            "collectionFormat": "multi",
            "allowEmptyValue": false,
            "enum": [
              "one",
              "two",
              "three",
              "four"
            ]
          }

Am I doing something wrong here. Please advice.

@SarveshSharma06 SarveshSharma06 changed the title AllowableValues for @ApiParam are not honored when request parameter is Collection Array AllowableValues for @ApiParam is not honored by Swagger when request parameter is Collection Array May 28, 2020
@SarveshSharma06
Copy link
Author

Hi,
It might not be a super critical buggy behavior, but would like to know if it is an actual bug and if there's a workaround on this?
Some insights would be really appreciated.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants