Repeated URL Parameters


#1

I am just starting to use RAML.

Most Web toolkits such as the servlet API in Java provide a list of parameter values for handling repeated parameters of the same name. It seems to be a cleaner approach than inventing a sub-syntax inside of a query parameter to have a list. Instead, you introduce each repeatable parameter value with the name of the query parameter, i.e.

http://mystorage.example.com/files?ext=foo&ext=bar&ext=garble&since=yesterday

This has three different filters that may apply to the file extension, which is intermingled with other single parameters.

I have seen nowhere that it is forbidden or permitted to repeat parameters in a RAML URL, so I assume it is permitted. I do not want to have to invent list sub-syntaxes that get escaped in their own way.

But I would have expected to see an additional property of query parameters, like required, but called something like “repeatable”, so we distinguish whether a parameter may be repeated. If required is important, then repeatable should be as well.


#2

Apologies, repeat is in the spec. I must have been looking in the wrong place.


#3

Yes repeat: true is there in the specification :slight_smile:


#4

Just to clarify repeat is indeed inside the RAML 0.8 specification but has been removed in RAML 1.0 in favour for RAML data types plus arrays.


#5

Thus in RAML 1.0 how can we express a repeatable query parameter of type number in a specified format?

with repeat it would have been easy

queryParameters:
  id:
    type: number
    format: long
    repeat: true

but this is not valid anymore in RAML 1.0.

Using type: number[] is far less expressive and leads to a documentation expressing a datatype array (different than repeatable for me)

Using an own defined type LongQueryParam could serve to express the long datatype but is far too complicated and does not render even in default viewer

types:
  LongQueryParam:
    type: number
    format: long
...
    queryParameters:
      id:
        type: LongQueryParam[]