Query parameters in RAML 1.0: multiple instances for enums


#1

I see from the RAML 1.0 documentation that multiple instances of query parameters can be indicated by using an array type.

What is the syntax for doing this when the property declaration uses an enum? Both of the following give syntax errors in API Workbench:

queryParameters:
  status?:
    enum[]: [ open, selected, rejected ]

queryParameters:
  status?:
    enum: [ open, selected, rejected ][]

#2

Let me know if that is what you want to achieve:

/resource:
  get:
    queryParameters:
      status?:
        type: array
        items:
          enum: [ open, selected, rejected ]

The serialized form would look like: resource?status=open&status=selected


#3

Yes, that’s perfect, thank you.


#4

My problem is a bit different. We want an array of string values. The list is too long to enumerate and does change so that the back end will do the verification.

Is there a way to deal with this?

Would
type: array
work without specification of items in an array?


#5

At the moment, the items field is indeed optional. There is some conversation about the default type if there is no items defined. See here.