1

In my api, I have a type who contains a map of uuid->Drive. I have used a Map type[1] to define that :

type: object
properties:
  drives:
    required: false
    type: object
    properties:
      [(a-zA-Z0-9-)*] :
         type: Drive

That work but I would like to be more precise on the pattern. However I can't manage to have it working.

  • ["(a-zA-Z0-9){8}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){12}"]: Don't seems to be used as regular expression.
  • [(a-zA-Z0-9){8}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){12}]: Say Missed comma between flow collection entries

How can I use a complex expession in a Map type with RAML 1.0 ?

(I'm using API Workbench)

[1] http://docs.raml.org/specs/1.0/#raml-10-spec-map-types

gervais.b
  • 2,294
  • 2
  • 22
  • 46

2 Answers2

0

Using patternProperties instead of the alternative syntax I don't have any errors in my RAML. However it seems that, API Workbench validates nothing.

gervais.b
  • 2,294
  • 2
  • 22
  • 46
0

You need to use a RegEx string that starts with /^ and ends with $/

#%RAML 1.0
title: My API With Types
types:
  Person:
    properties:
      name:
        required: true
        type: string
      age:
        required: false
        type: number
      /^note\d+$/: # restrict any properties whose keys start with "note"
                   # followed by a string of one or more digits
        type: string

https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#additional-properties