In RC1, the specification does not contain information about the serialization of type instances to XML. As the serialization to XML may be a complex process, RAML 1.0 RC2 introduces an additional xml node for type declarations that allows to configure how type instances should be serialised to XML.
The value of the xml node is a map that contains the following properties:
Name
Type
Description
attribute?
boolean
If attribute is set to true, a type instance should be serialized as an XML attribute. It can only be true for scalar types.
Default:false
wrapped?
boolean
If wrapped is set to true, a type instance should be wrapped in its own XML element. It can not be true for scalar types and it can not be true at the same moment when attribute is true.
Default:false
name?
string
Allows to override the name of the XML element or XML attribute in it's XML representation.
Default: the name of the type
namespace?
string
Allows to configure the name of the XML namespace.
prefix?
string
Allows to configure the prefix which will be used during serialization to XML.
The following is a type declaration example that uses the xml node:
types:
Person:
properties:
name:
type: string
xml:
attribute: true # serialize it as an XML attribute
name: "fullname" # attribute should be called fullname
addresses:
type: Address[]
xml:
wrapped: true # serialize it into it's own <addresses>...</addresses> XML element
Address:
properties:
street: string
city: string
The example above may be serialized into the following XML:
In RC1, the specification does not contain information about the serialization of type instances to XML. As the serialization to XML may be a complex process, RAML 1.0 RC2 introduces an additional
xml
node for type declarations that allows to configure how type instances should be serialised to XML.The value of the
xml
node is a map that contains the following properties:boolean
attribute
is set totrue
, a type instance should be serialized as an XML attribute. It can only betrue
for scalar types.Default:
false
boolean
wrapped
is set totrue
, a type instance should be wrapped in its own XML element. It can not betrue
for scalar types and it can not betrue
at the same moment whenattribute
istrue
.Default:
false
string
Default: the name of the type
string
string
The following is a type declaration example that uses the
xml
node:The example above may be serialized into the following XML: