RAML字符串数组中项目的最大长度

时间:2019-05-31 11:12:41

标签: mule raml raml-1.0

我正在定义RAML规范。我有一个属性来保存字符串数组。我要制定一个规则,即数组中的字符串值最多只能有3个字符(例如:regions: ["wes","nrh"]有效。regions: ["lenghthyvalue", "anotherLenghthyvalue"]无效)。我如何在RAML中处理它。我当前的代码如下:

regions:  
     type: string []
     required: true

可用属性仅是maxItems。如何限制项目的字符长度?

我使用raml 1.0

1 个答案:

答案 0 :(得分:1)

First create a string type that has maxLength and minLength attributes. Then you can reference that type in your array type instead of just a string array. Example:

#%RAML 1.0
title: test
version: 1.0
types:
  region:
    type: string
    minLength: 3
    maxLength: 3
  regions:  
     type: region []
     required: true

/test:
  get:
    queryParameters:
      regions: region