如果我有一个定义数据类型SimpleDuple的文件,而在另一个文件中定义了另一个数据类型DiscreetFilter,我想拥有一个属性values作为SimpleDuple数组,我将如何使用include呢?

考虑一下SimpleDuple的文件:

#%RAML 1.0 DataType
type: object
properties:
  id: string
  name: string

我想要使​​属性成为的另一个定义是values属性中的SimpleDuples数组(但我必须使用内联定义)。
#%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属性设置为SimpleDuple[]。如果不是数组,则将include作为values属性的值。

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

最佳答案

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

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

希望有帮助吗?

关于arrays - 如何在Raml中的外部文件中定义类型的数组?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34886455/

10-16 15:51