Can a user select whether or not to pass variables? #57

Closed
switzer opened this Issue Nov 21, 2012 · 2 comments

3 participants

@switzer

When using IODocs as an API explorer, I would like to decide whether or not to pass a variable at all. For example, if I want to have an endpoint that lists users, I would like to be able to have a querystring variable that, if present, either filters users that are active or inactive. So, the following URL's would return the following:

http://api.example.com/v1/users - return a list of all users
http://api.example.com/v1/users?active=true - return a list of active users only
http://api.example.com/v1/users?active=false - return a list of inactive users only

Is there a way to define my API in IODocs so that I can use the API to construct all three URL's (including the first one which I cannot find a way to do if I create an 'active' querystring variable).

Perhaps one UI technique would be to have an 'x' all the way right which appears on mouseover, and if you click the 'x', the box is grey'ed out.

Thanks!

@vky
{
    "name": "Example Endpoint",
    "methods": [
        {
            "MethodName": "Get users",
            "Synopsis": "Returns a list of users.",
            "HTTPMethod": "GET",
            "URI": "/v1/users",
            "RequiresOAuth": "N",
            "parameters": [
                {
                    "Name": "active",
                    "Required": "N",
                    "Default": "",
                    "Type": "enumerated",
                    "EnumeratedList": [ "", true, false],
                    "EnumeratedDescription": {
                        "''": "Return a list of all users",
                        "true": "Return a list of active users only",
                        "false": "Return a list of inactive users only"
                    }
                }
            ]
        }
    ]
}

I noticed after making this example that this post is 3 months old. Hope you've already found a solution; if not, I believe this should do about what you asked. The empty string in EnumeratedList is redundant with Default also set as an empty string, so one of those can be removed. With an empty string, the first case you listed should be generated, and with true and false, the second and third cases respectively should be generated.

@mansilladev

Thank you Vijay. That is correct.

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