Include library in datatype definition


#1

Hi all.

I’m trying to define a DataType which includes other more basic DataType’s:

#%RAML 1.0 DataType
type:
  object
properties:
  id: integer
  prop1: !include proptype1.raml
  prop2: !include proptype2.raml
  ...
  propnN: !include proptypeN.raml

The problem is that for each property I have to create a separate .raml file containing the data type definition. Most of them are one liner.

Is there any way to create a library and import all the data types defined there and use in my datatype definition?

basic.raml:

#%RAML 1.0 Library
types:
  proptype1: ...
  proptype2: ...
  ...
  proptypeN: ...

datatype.raml:

#%RAML 1.0 DataType
uses:
  basic: !include basic.raml
types:
  MyType:
    type:
      object
    properties:
      id: integer
      prop1: basic.proptype1
      prop2: basic.proptype2
      ...
      propnN: basic.proptypeN

#2

Hi @superruzafa,

Currently that is a limitation in RAML 1.0 RC1 that we want to fix for sure. You can track the related issue here that also includes having uses available in all RAML fragments. See:

This proposal also expands the use of uses to allow its use in a root (“master”) RAML file as well as in all RAML fragment files.


#3

Great. In the meantime I’ll use libraries instead.

Thank!