Определить пространство имен XML в типе данных RAML - PullRequest
0 голосов
/ 09 октября 2018

Можно ли определить пространство имен XML в типе данных RAML?Я нашел ссылку на это возможным в спецификации RAML на github , но я не могу заставить ее работать в MuleSofts API Designer.

Например, я думал, что могу определить свой RAML, как показано ниже, но я получаю сообщение об ошибке в API Designer, что ожидаемый тип является объектом, но он получил строку.

#%RAML 1.0 DataType


type: object
properties: 
  top:
    type: object
    properties: 
      abc:
        xml:
          attribute: true
          name: abc 
      xmlNamespace:
        xml: 
          attribute: true
          namespace: http://google.com
      node:
        type: string
example:
  <xml>
    <top abc="123" xmlns="http://google.com">
      <node>12345</node>
    </top>
  </xml>

1 Ответ

0 голосов
/ 15 ноября 2018
namespace is for when the xml element should have a namespace like so:

#%RAML 1.0 DataType
  properties: 
    top:
      type: object
      xml:
        name: top
        wrapped: true
        namespace: f
      properties: 
        abc:
          xml:
            attribute: true
            name: abc
  example:
    <mytype>
      <f:top abc="123">
      </f:top>
    </mytype>

если вы просто хотите, чтобы атрибут называл xmlns, то, возможно, попробуйте что-то вроде этого:

#%RAML 1.0 DataType
  properties: 
    top:
      type: object
      xml:
        name: top
        wrapped: true
      properties: 
        abc:
          xml:
            attribute: true
            name: abc
        xmlns:
          default: http://google.com
          xml:
            attribute: true
            name: xmlns

  example:
    <mytype>
      <top abc="123" xmlns="http://google.com">
      </top>
    </mytype>
...