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

Multiple Allowable Values for Lists does not show options in UI #1329

Closed
smwurster opened this issue May 27, 2016 · 4 comments
Closed

Multiple Allowable Values for Lists does not show options in UI #1329

smwurster opened this issue May 27, 2016 · 4 comments
Labels
Milestone

Comments

@smwurster
Copy link

When an ApiModelProperty is on a List type, the allowableValues entry is not shown in the UI.

When the code looks like this:

@ApiModelProperty(value="a list of values", allowableValues="foo,bar,baz", required=false)
public void setValues(List<String> values) {
    this.values = values;
}

The generated JSON looks like this:

"values": {
    "type": "array",
    "description":  "a list of values",
    "items": {
        "type": "string",
        "enum": [
            "foo",
            "bar",
            "baz"
        ]
    }
}

But it should look like this:

"values": {
    "type": "array",
    "description": "a list of values",
    "items": {
        "type": "string"
    },
    "enum": [
        "foo",
        "bar",
        "baz"
    ]
}

This occurs in version 2.4.0.

@dilipkrish
Copy link
Member

@smwurster that looks right to me. The what it should look like is an artifact of a bug in swagger-ui/swagger-editor.

To me it is difference between Values is an array of enums ✅ vs Values is an array of string and an enum

May be we can get clarification from OAS?

@smwurster
Copy link
Author

Hmmm. The Schema definition also contains "enum", which is probably why for a single value with allowable values we get something like this:

"someValue": {
    "type": "string",
    "description": "asdf",
    "enum": [
        "foo",
        "bar"
    ]
}

So which is correct?

If there's a bug in the UI portion, could you fix it in your version, or do you just pull that directly from an external source?

@dilipkrish
Copy link
Member

It is a bug in the ui. However I don't maintain the ui libraries, just a mirror with slight modifications.

@smwurster
Copy link
Author

Ah, looks like they fixed it in the spec, but Swagger Core hasn't caught up.

I wonder if I could work around this with a local fork...

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