I have been reading through the specification, but I can’t understand the part about " XML Serialization of Type Instances" https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#xml-serialization-of-type-instances
Using MuleSoft’s API designer I have been trying to test the example given in the specification, using the following code:
#%RAML 1.0 title: test version: 1 types: Person: !include datatypes/Person.raml Address: !include datatypes/Address.raml /customer: post: body: application/xml: type: !include datatypes/Person.raml responses: 200: body: application/xml: type: !include datatypes/Person.raml
#%RAML 1.0 DataType type: object 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: false examples: ex1: !include ../Examples/PersonExample.raml
#%RAML 1.0 NamedExample value: name: TestName addresses: - street: TestStreet 1 city: TestCity
When I test the API this is the XML that is returned to me:
<?xml version="1.0" encoding="UTF-8"?> <model> <addresses> <address> <city>TestCity</city> <street>TestStreet 1</street> </address> </addresses> <name>TestName</name> </model>
but according to the specification this is the result I should have got:
<Person fullname="John Doe"> <addresses> <Address>…</Address> ... </addresses> </Person>
What I’m I missing?
Also, when I play around and either try to remove the
xml: wrapped: true
or change wrapped to “false” I don’t see any difference? What’s wrong.
Can anybody please help my understand XML wrapped?