如何定义在RAML外部文件的类型的数组? [英] How to define an array of a type in an external file in Raml?

查看:542
本文介绍了如何定义在RAML外部文件的类型的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有定义数据类型 SimpleDuple ,而在另一个文件中定义 DiscreetFilter 叫其它数据类型我想要的文件有一个属性是数组 SimpleDuple 我怎么会用包括有?

If I have a file defining a Datatype SimpleDuple, and in another file defining another datatype called DiscreetFilter I want to have a property values to be an array of SimpleDuple how would I use include there?

考虑文件SimpleDuple:

Consider the files for SimpleDuple:

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

和我想要做一个财产SimpleDuples在属性的阵列(但我不得不使用内联的定义)的其他定义。

And the other definition where I want to make a property be an array of SimpleDuples in the values property (but I had to use an inline definition).

#%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

如果这两种类型,其中在同一个文件我会在属性设置为 SimpleDuple [] 。如果不是一个数组我把包括作为属性的值。

If those two types where on the same file I'd set the values property to SimpleDuple[]. If it wasn't an array I'd put the include as the value of the values property.

但我怎么使用包含并在同一时间一个数组,而不是使用我的复制code使用内联定义的?

But how do I use an include and an array at the same time instead of using the inline definition I used in the copied code?

推荐答案

您应该能够做到以下几点:

You should be able to do the following:

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

希望帮助!

这篇关于如何定义在RAML外部文件的类型的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆