Nested NamedExamples


#1

I have created some nested data types in my RAML spec e.g. a Unit and Position data type.

The Position data type has Unit nested in it like so:

#%RAML 1.0 DataType
type: object
properties:
positionID: {
type: string,
required: true,
description: System ID for this unit.
}
unit: {
type: !include UnitType.raml,
required: true,
description: Unit in which this position sits.
}

This seems to work OK in my spec but I would like to include examples as well as types. Is it possible to nest the NamedExample as well? My current attempts are failing.

I have a NamedExample for Unit and am trying to !include this in the Position NamedExample as below:

#%RAML 1.0 NamedExample
PositionExample:
positionID: f33lijf2lij
parent: 32j2fj29f
fteAmount: 1
unit: !include UnitExample.raml
jobTitle: Analyst

However, I am getting the error in my spec “unit should be object at examples/PositionExample.raml”

How do I declare an object in an include?

Thanks

Sean


#2

I have found I can get this to work if I re-type the entire sub object into the NamedExample e.g.

#%RAML 1.0 NamedExample
PositionExample:
  positionID: f33lijf2lij
  parent: 32j2fj29f
  fteAmount: 1
  unit:
    unitID: adl23f33j
    unitName: IT Services

However, it would be nicer if I could include the other example file rather than retype this.