swagger2markup icon indicating copy to clipboard operation
swagger2markup copied to clipboard

Example values of nested objects are rendered as JSON with escaped <br> in them

Open alkemann opened this issue 8 years ago • 1 comments

Consider a swagger that includes this on the a resource definition:

errorContext:
  type: object
  description: Map with additional error information
  example:
    field: currency

The markdown that is generated looks like this:

|**errorContext**  <br>*optional*|**Example** : `{<br>  "field" : "currency",<br>  "message" : "Wrong currency code"<br>}`|object|

And this markdown gets converted into this HTML:

<tr>
<td><strong>errorContext</strong>  <br><em>optional</em></td>
<td>Map with additional error information  <br><strong>Example</strong> : <code>{&lt;br&gt;  "field" : "currency"&lt;br&gt;}</code></td>
<td>object</td>
</tr>

Obviously the &lt;br&gt; in the JSON blobs are not desired.

alkemann avatar Oct 09 '17 13:10 alkemann

errorContext:
  type: string
  description: Map with additional error information
  example: '{"field": "currency", "message": "Wrong currency code"}'

By enclosing the JSON example within double quotes and treating it as a string, you can avoid the unwanted
tags in the generated Markdown |errorContext <br>optional|Example : {"field": "currency", "message": "Wrong currency code"}|object|

ljluestc avatar Jun 27 '23 06:06 ljluestc