0

I'm using an <example> tag to document a variable like this: https://learn.microsoft.com/en-us/dotnet/csharp/codedoc#example

Later, it is being used to generate XML Documentation Swagger relies on.

It works great for numerical or string values. But my variable contains an XML string. As soon as I place xml inside of an <example> tag, it tries to parse it and fails with the following message: XML comment has badly formed XML. I've already tried escaping xml string and putting it into braces with no success. Though an exception disappears, swagger defaults to string instead of showing my example.

Is there any way to use <example> tags with xml content inside?

Hirasawa Yui
  • 1,138
  • 11
  • 29
  • Have you tried to use [CDATA to indicate that the nested xml is just data and shouldn't be parsed as XML?](https://stackoverflow.com/questions/2784183/what-does-cdata-in-xml-mean)? – omajid Jun 15 '21 at 14:55
  • Yes, CDATA it didn't help. I just got the same `string` text. – Hirasawa Yui Jun 15 '21 at 15:12
  • CDATA is the solution. You need to show us what you did and how it failed so we can tell you what you did wrong. – Michael Kay Jun 15 '21 at 17:06

0 Answers0