3

I want to model an API with RAML 1.0. Within this API I have a map where the included objects have dynamic key values. It should look like the following:

"map" : {
   "key1" : {
       ...
   }
   "key2" : {
       ...
   }
   "key3" : {
       ...
   } 
}

In this stackoverflow article I found a solution for the dynamic keys but now I am stuck. How can I create the map? For sure I can do a workaround with array, but this is not what I am looking for.

Cheers.

Mirza Sisic
  • 2,401
  • 4
  • 24
  • 38

1 Answers1

-1

According to https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#property-declarations and to https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#the-any-type

following should work:

#%RAML 1.0 Library
types:
  TypeWithMap:
    properties:
      name: string
      map:
        properties:
          //: any

Also, you can find full discussion at https://github.com/raml-org/raml-spec/issues/573

Prateek Jain
  • 2,738
  • 4
  • 28
  • 42