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

Enum values not displayed in models

Open sosoxuc opened this issue 12 years ago • 24 comments

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

sosoxuc avatar Oct 19 '14 00:10 sosoxuc

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

fehguy avatar Oct 19 '14 00:10 fehguy

"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"
                    }
                }
            }
        }

sosoxuc avatar Oct 19 '14 00:10 sosoxuc

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

fehguy avatar Oct 19 '14 00:10 fehguy

I have changed title because second part was not an issue

sosoxuc avatar Oct 19 '14 01:10 sosoxuc

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

emanic avatar Oct 23 '14 21:10 emanic

is this a swagger 2.0 spec or 1.2?

fehguy avatar Oct 23 '14 21:10 fehguy

2.0

emanic avatar Oct 23 '14 21:10 emanic

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.

fehguy avatar Oct 23 '14 21:10 fehguy

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!

emanic avatar Oct 23 '14 21:10 emanic

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.

fehguy avatar Oct 23 '14 21:10 fehguy

All right, great! Thanks... :)

emanic avatar Oct 23 '14 21:10 emanic

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?

eloleon avatar Jan 05 '15 11:01 eloleon

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

webron avatar Jan 05 '15 11:01 webron

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

eloleon avatar Jan 05 '15 11:01 eloleon

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

webron avatar Jan 05 '15 12:01 webron

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

tshah010-zz avatar Feb 06 '15 00:02 tshah010-zz

Please note that it's targeted for 2.1.0-M2

fehguy avatar Feb 06 '15 00:02 fehguy

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

nicolastrres avatar Apr 28 '15 20:04 nicolastrres

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

webron avatar Apr 29 '15 16:04 webron

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

hiveship avatar May 31 '16 08:05 hiveship