Object with any properties where all values are a defined type


#1

If I have a type:

Link:
type: object
properties:
name: string
uri: string

I would like my API to allow an object that looks like this:
{
foo: {
name:‘me’,
uri:’/me/home’
},
bar: {
name:‘you’,
uri:’/your/home’
}
}

But what I really want is any kind of Map. Like if it were Java, I would defined it as Map<String,Link> where the properties can be ANY key. Can this be done with RAML 1.0?


#2

For sure. I think what you want is something like this:

types:
  Link:
    type: object
    properties:
      name: string
      uri: string
  MyMap: string | Link