Array type as a queryParam


#1

I wonder if it is possible to define an array type as a queryParam?

i want to represent in raml :

/resources/?state=open,close

where each state can be new,open,or close

thx


#2

Unfortunately, you can’t. The following types are allowed: string, number, integer, file, date, or boolean. What you could do is using a string and in your description say that it is a comma separated list for people discovering your API.


#3

You can also declare status as a repeated parameter and then use &status=open&status=closed. Of course this assumes your REST implementation can deal with repeated parameters (e.g. Spring MVC can automatically map these to Array/List Java parameter types).


#4

thx for your reply.

i knew the repeated flag, but it does not fit to our way to implement the multiple values for a parameter.


#5

+1 on this problem.

I’m using RAML to specify a POST request that uses an array-type query parameter (so comma-separated values do not work for me).

It seems like the type parameter should reasonably adopt the set of possible JSON data types, since many RAML users are using it to represent JSON.

This represents a hack in the RAML language, for me.

I’m also unable to use Markdown in the example value for this parameter, so I don’t have a way to aesthetically present example data, either.