属性 'MaxOccurs' 不能出现在元素 'element' 中。”在 RAML 定义中

Attribute 'MaxOccurs' cannot appear in element 'element'." In RAML defination

我在为 Xml 输入定义 Raml 时收到此错误,但是我收到此错误,我已经知道 xsd 已回答此问题,但我没有 xsd 在 Raml

任何人都可以建议如何在 xml 设计中定义数组的解决方案 因为我已经完成了下面的 Url

https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#array-type

输入:

<numbers>
    <value>3</value>
    <value>2</value>
    <value>1</value>
</numbers>


#%RAML 1.0
title: Claim Request
version: 0.1
baseUri: http://localhost:8767/claim
mediaType: [ application/xml ]
protocols: HTTP
types:
  value:
    type: string
  numbers:
    type: value[]
    uniqueItems: true
/claimDemo:
  post: 
   body:
    type : numbers
   responses: 
    200:
     body: 
      application/json:
       example: |
              {
                "message" : "Hello World"
              }

输出:

Exception stack trace:
 org.mule.module.apikit.exception.BadRequestException: Error validating XML.     Error: s4s-att-not-allowed: Attribute 'maxOccurs' cannot appear in element 'element'.
at  org.mule.module.apikit.HttpRestRequest.validateSchemaV2(HttpRestRequest.java:539)
at org.mule.module.apikit.HttpRestRequest.validateBody(HttpRestRequest.java:379)
at org.mule.module.apikit.HttpRestRequest.negotiateInputRepresentation(HttpRestRequest.java:353)
at org.mule.module.apikit.HttpRestRequest.validate(HttpRestRequest.java:125)
at org.mule.module.apikit.AbstractRouter.processRouterRequest(AbstractRouter.java:205)

尝试这样的事情:

#%RAML 1.0
title: Claim Request
version: 0.1
baseUri: http://localhost:8767/claim
mediaType: [ application/xml ]
protocols: HTTP
types:
  value:
    type: string
  numbers:
    type: value[]
    maxItems: 3
    uniqueItems: true
/claimDemo:
  post: 
   body:
    type : numbers
   responses: 
    200:
     body: 
      application/xml:
       example: |
              {
                "message" : "Hello World"
              }

根据以下文档:https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#xml-serialization-of-type-instances 您可以使用 wrapped 选项,这将允许您避免在此处定义时遇到的问题。

参见下面的示例

#%RAML 1.0
title: Claim Request
version: 0.1
baseUri: http://localhost:8767/claim
mediaType: [ application/xml ]
protocols: HTTP
types:
  value: string
  numbers:
    type: value[]
    xml:
      wrapped: true

/claimDemo:
  post: 
   body:
    type: numbers
   responses: 
    200:
     body: 
      application/json:
       example: |
              {
                "message" : "Hello World"
              }

作为附加说明,如果您删除了数组定义即:更改:

,则说明初始示例中错误的来源
  numbers:
    type: value[]
    uniqueItems: true

  numbers:
    type: value

那么您将能够使用如下输入:

<numbers value="a">