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

Enum values not displayed in models #672

Closed
sosoxuc opened this issue Oct 19, 2014 · 24 comments
Closed

Enum values not displayed in models #672

sosoxuc opened this issue Oct 19, 2014 · 24 comments

Comments

@sosoxuc
Copy link

sosoxuc commented Oct 19, 2014

I think not showing available values in model makes API unclear.

@fehguy
Copy link
Contributor

fehguy commented Oct 19, 2014

please give more info, and better yet, a sample spec.

@sosoxuc
Copy link
Author

sosoxuc commented Oct 19, 2014

"definitions": {
        "Menu": {
            "properties": {
                "menuId": {
                    "type": "string"
                },
                "partId": {
                    "type": "string"
                },
                "menuName": {
                    "type": "string"
                }
            }
        },
        "Part": {
            "properties": {
                "partId": {
                    "type": "string"
                },
                "partName": {
                    "type": "string"
                },
                "moduleId": {
                    "type": "string"
                },
                "menus": {
                    "type": "array",
                    "items": {
                        "$ref": "Menu"
                    }
                }
            }
        },
        "Module": {
            "required":[  
                "moduleId"
            ],
            "properties": {
                "moduleId": {
                    "type": "string",
                    "required" :true,
                    "description": "Unique identifire for the Module"
                },
                "moduleName": {
                    "type": "string"
                },
                "moduleVersion": {
                    "type": "string"
                },
                "moduleState": {
                    "type": "string",
                    "default": "",
                    "enum":[  
                        "STOPED",
                        "STARTED",
                        "DISABLED"
                    ]
                },
                "moduleDescription": {
                    "type": "string"
                },
                "moduleUrl": {
                    "type": "string"
                },
                "moduleIconUrl": {
                    "type": "string"
                },
                "moduleInfoUrl": {                    
                    "type": "string"                    
                },
                "parts": {
                    "type": "array",
                    "items": {
                        "$ref": "Part"
                    }
                }
            }
        }

@fehguy
Copy link
Contributor

fehguy commented Oct 19, 2014

OK so you're talking about model properties having allowable values. thanks

@sosoxuc sosoxuc changed the title Enum values not displayed in models nor passed in try out Enum values not displayed in models Oct 19, 2014
@sosoxuc
Copy link
Author

sosoxuc commented Oct 19, 2014

I have changed title because second part was not an issue

@emanic
Copy link

emanic commented Oct 23, 2014

I am also encountering this issue. The enum values do not show up in the swagger-ui. In addition, the "description" does not show up either. Here is some example code and screenshot of the result.
screen shot 2014-10-23 at 2 34 56 pm

screen shot 2014-10-23 at 2 24 22 pm

@fehguy
Copy link
Contributor

fehguy commented Oct 23, 2014

is this a swagger 2.0 spec or 1.2?

@emanic
Copy link

emanic commented Oct 23, 2014

2.0

@fehguy
Copy link
Contributor

fehguy commented Oct 23, 2014

Thanks, but just to be clear, you're only talking about allowable values for a model property. The enum is supported in operation parameters now, but yes, what you're describing is a bug.

@emanic
Copy link

emanic commented Oct 23, 2014

All right. Hm. Are you saying that what is called an "enum" in the JSON is not an "enum", but rather "allowable values for a model property"? That is OK, I guess, but we are calling them enums in our API, for better or for worse. So what shows up as "enum" in the example JSON is also considered an enum in the context of our API. Not sure of the details here, but it basically consists of a set of fixed values which cannot be deviated from in your operations. Thanks!

@fehguy
Copy link
Contributor

fehguy commented Oct 23, 2014

No, you're doing the right thing. It's called enum and they are effectively describing what values are allowed for a model property. They should work but are not implemented in the UI. Follow this ticket and it'll get fixed.

@emanic
Copy link

emanic commented Oct 23, 2014

All right, great! Thanks... :)

@fehguy fehguy added this to the v2.1.0-M2 milestone Dec 29, 2014
@eloleon
Copy link

eloleon commented Jan 5, 2015

Hi all, I'm getting same issue. It would be great if option for defining available values by using enums would be available. webron said that I should create issue here but there is one already ( http://stackoverflow.com/questions/27603871/how-to-define-enum-in-swagger-io ).
Do you think it will be solved anytime soon?

@webron
Copy link
Contributor

webron commented Jan 5, 2015

Well, don't blame me. I don't remember all opened issues ;)

@eloleon
Copy link

eloleon commented Jan 5, 2015

It was my bad, I should check issue list here before posting question. Thanks for all you suggestions

@webron
Copy link
Contributor

webron commented Jan 5, 2015

No worries, it's not easy finding all available information.

@tshah010-zz
Copy link

Hi, has this issue been fixed? If yes, which version is it available in? Thanks.

@fehguy
Copy link
Contributor

fehguy commented Feb 6, 2015

Please note that it's targeted for 2.1.0-M2

@nicolastrres
Copy link

Hi all I am getting the same issue. Is this fixed?

@webron
Copy link
Contributor

webron commented Apr 29, 2015

@nicolastrres - should be fixed. If not in master then in develop_2.0.

@hiveship
Copy link

I'm still facing the problem with the current master branch.
I've reported it in issue 2184

@SonnyRajagopalan
Copy link

Still have this issue (enums in *.yaml not displaying in UI). Is it going to be fixed soon?

@webron
Copy link
Contributor

webron commented Apr 14, 2017

@SonnyRajagopalan there shouldn't be an issue with the latest master. If you encounter an issue, open a new ticket and provide a full spec that reproduces the problem.

@SonnyRajagopalan
Copy link

@webron , My profound apologies. Tooling error on my part (dealing with an obscenely large spec so I have tools that generate metadata that generate more metadata which finally generate yaml code...). It works just fine. Thanks a heap for your quick response!

@s0meRandomDev
Copy link

Had the same problem, it would appear that an enum without a "type" specified is not displayed in swagger UI. Adding the "type" to the field definition was enough for it to work.

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

No branches or pull requests