raml-spec icon indicating copy to clipboard operation
raml-spec copied to clipboard

xml:name when xml:wrapped is true

Open KevinMitchell opened this issue 6 years ago • 2 comments

The spec contains the following example:

types:
  Person:
    properties:
      addresses:
        type: Address[]
        xml:
          wrapped: true 

If I also include a name node, e.g. name: foo, which element name does this override, the outer element name or the inner one? And how do I override the other one? It looks like we have two names, and only one name node, which is why I was expecting the wrapped node to be of string type, rather than a boolean.

KevinMitchell avatar Jul 13 '18 22:07 KevinMitchell

@KevinMitchell: not sure to understand your question. Can you provide an example of both the RAML type definition with that extra name property and an XML representation that you may expect?

jstoiko avatar Jul 20 '18 19:07 jstoiko

In the spec it includes the example I quoted, with the serialised output as

<Person>
  <addresses>
     <Address>…</Address>
     ...
  </addresses>
</Person>

I've omitted the name property that was also in the example from the spec. So the addresses element is coming from the property name, and the name of the inner Address element is coming from the type name?

So if we extend the example so the xml node now looks like this:

xml: 
  wrapped: true
  name: foo

I assume that the outer element will now be named <foo>...</foo> and the inner element will still be named after the type? I was simply asking if this assumption was correct. And if so, why the wrapped node didn't take a string rather than a boolean, as in this example there are two names, addresses and Address, and in general you'd like to be able to alter both of them.

KevinMitchell avatar Jul 25 '18 07:07 KevinMitchell