Forum Discussion

priya721's avatar
priya721
New Contributor
2 years ago

Namespace to an XML object get repeated to every child tag

Version which I am using now is OpenApi2.0. I am trying to add xml sample object to request body. XML is getting populated but the issue is with namespace it get added to every child tag. Please see below.
<SampleRequest xmlns="https://exmpale.com">
<Id xmlns="">123471</Id>
<Message xmlns="">XYZ</Message>
<SampleRequest>

open api json:
"LabelRequestModel": {
"type": "object",
"xml": {
"name": "SampleRequest",
"namespace":"https://exmpale.com",
"attribute":true
},
"properties": {
"Id": {
"type": "integer",
"xml": {
"name": "Id"
},
"format": "int32",
"default": 123471
},
"Message": {
"type": "string",
"xml": {
"name": "Message"
},
"default": "XYZ"
}
}

  • Hi priya721 ,

     

    We'd need more details... what are you using to form those XML bodies? The way you've described the XML object seems fine, and if I render an example in SwaggerUI, I see this...

     

     

    In other words, how can someone reproduce the steps to show your results?

    It sounds like its likely a bug with whichever tool you're using, in that it is always rendering the xmlns attribute, even if it is empty.

     

     

    • priya721's avatar
      priya721
      New Contributor

      Hi ponelat,

      We use swagger 2.0 version to define our api. HAPI portal loads our api to make them accessible for users. Even I tried my swagger json in editor, request body xml is loading well and good.

       

      Thanks!

      Priya