loic911 / Rest-api-doc

MIT License
21 stars 32 forks source link

Optional query parameters that don't require values #38

Open raffian opened 10 years ago

raffian commented 10 years ago

Our REST services return hierarchical data. Some clients, however, prefer flat data, so we offer the option to flatten the response using this convention:

/customer{customer_id}/?$flatten

We documented $flatten like this..

   @RestApiParam(name="$flatten", 
                 type="String",
                 paramType = RestApiParamType.QUERY)
defaultParamsQueryAll = 
   [[name:'$flatten',
     paramType = RestApiParamType.QUERY,
     description:"Flattens response to tabular format"]

In both cases, however, the parameter displays with an input field in Playground; this is normal, but not normal for parameters that don't take values, creating request URL like this:

/customer{customer_id}/?$flatten=

We suggest support for new parameter type:

paramType = RestApiParamType.QUERY_NOVAL

For such parameters, instead of showing input field in Playground, show checkbox instead, when selected, the parameter (without a value) is added to the query string:

/customer{customer_id}/?$flatten