1

I am working with Swagger to define my api definition. I have a comments that I need to define using swagger.

sbhatt
  • 331
  • 1
  • 3
  • 15

1 Answers1

2

CDATA is not part of XML logical structure, it's just a way to indicate text containing special characters - in order to prevent such text from being interpreted as XML markup.

Simply define CDATA's parent element as type: string, that's all. There's no need to indicate CDATA markers in any way. It's up to the server and clients to send an XML element's text as CDATA when necessary.

For example

<root>
  <elem><![CDATA[ ... ]]></elem>
</root>

is defined as:

swagger: "2.0"
...

definitions:
  root:
    type: object
    properties:
      elem:
        type: string
Helen
  • 71,797
  • 10
  • 199
  • 256