Getting additional properties inheritance to work?


#1

I’m trying to declare a RAML 1.0 type that restricts all its properties to be of a specific type.
Based on the specfication (RAML Data Types -> Additional properties), I would expect the following definition to work, however the API Workbench complains with the error:

Error: map property mapPropertyIs conflicts with property:self

# See: https://tools.ietf.org/html/draft-kelly-json-hal-08#page-4
types:
  HalLink:
    properties:
      href: string
      name?: string
      templated?: boolean
      type?: string
  HalLinks:
    properties:
      //: HalLink

  Test:
    type: HalLinks
    properties:
      self: HalLink

What am I doing wrong?


#2

Additional properties are only for data instances, not on type properties. So, for example:

types:
  HalLink:
    properties:
      href: string
      name?: string
      templated?: boolean
      type?: string
  HalLinks:
    properties:
      //: HalLink
    example:
      self:
        href: any url

The important part here is what;s inside the example node as this represents a data instance. If you would send some data to your service and test that instance against what you defined in RAML, each property value inside the instance should be a HalLink.

Hope that helps.