Forum Discussion

skmutyala's avatar
New Member
3 years ago

How to represent xml attribute and value in swagger yml

I am trying to define the api yaml to represent an xml object. Can some one please share how can we define the below xml with an attribute field in yaml.


The Name element has lang attribute - "en" and value - "BigName", how can we define in yaml?



    <Name lang="en">BigName</Name>



Thank you in advance.

1 Reply

  • HKosova's avatar
    SmartBear Alumni (Retired)

    Hi skmutyala,


    OpenAPI Specification currently has no way to represent XML elements with attributes such as

    <elem attr="value">Some text</elem>


    Currently, attributes can only be defined for objects such as

    <obj attr="value">
      <elem>Some text</elem>

    but not for simple <elem>text</elem> elements.


    There's an open issue about this limitation in the OpenAPI Specification repository:

    How to represent XML elements with attributes


    OpenAPI Specification maintainers are considering an option to use alternative data modeling schemas (for example, XSD Schema), so your use case might be supported in a future version of OpenAPI.