如何在Raml中定义外部文件中的类型数组?

时间:2016-01-19 20:34:54

标签: arrays types include modularity raml

如果我有一个定义数据类型SimpleDuple的文件,并且在另一个定义另一个名为DiscreetFilter的数据类型的文件中,我想让一个属性values成为{{1}的数组我将如何使用include?

考虑SimpleDuple的文件:

SimpleDuple

我要创建属性的另一个定义是#%RAML 1.0 DataType type: object properties: id: string name: string 属性中的SimpleDuples数组(但我必须使用内联定义)。

values

如果同一文件中的这两种类型我将#%RAML 1.0 DataType type: object properties: field: string name: string type: { enum: [ discreet ] } # Ideally this property would use an include # in some way to express the equivalent of SimpleDuple[] values: type: array properties: id: string name: string 属性设置为values。如果它不是数组,我会将include作为SimpleDuple[]属性的值。

但是如何同时使用include和数组而不是使用复制代码中使用的内联定义?

1 个答案:

答案 0 :(得分:12)

您应该能够执行以下操作:

<强> chapter.raml

#%RAML 1.0 DataType

type: object
properties:
  name: string

<强> storyboard.raml

#%RAML 1.0 DataType

type: object
properties:
  name: string
  chapters:
    type: array
    items: !include chapter.raml

希望有帮助吗?!