Restricting valid choices for arrays of one string

I’m trying to use the RAML 1.0 type system to create some types which are just a string. I’m passing these items across the API as JSON, so I don’t want to pass a bare string, rather an array containing a single string. (Our JSON libraries don’t like bare strings.) If I didn’t have this array restriction, I would do this:

my_flag:
    type: string
    enum: [ "ready", "not_ready" ]

Is there a way I can have the same kind of restriction which the enum provides, but on a string array type instead?

my_flag:
    type: string[]
    ???

I’d also be interested to know if there was another way to pass these kind of flags. I’m very new to all of this.

If I understand correction, you are attempting to define an array of strings and restrict the values of that array to certain specific values. If so, I think you were close.

my_flag:
    type: array
    items:
        type: string
        enum: [ "ready", "not_ready" ]

and since type can be inferred in RAML and the default type is “string”, you can simply write:

my_flag:
    items:
        enum: [ "ready", "not_ready" ]
1 Like