Newlines in description fields are converted to <br>
See original GitHub issueQ&A (please complete the following information)
- OS: Linux
- Browser: Chrome
- Version: 67
- Method of installation: npm
- Swagger-UI version: 3.17.0
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
Example Swagger/OpenAPI definition: https://his-dev.mmprototype.net/api/v1/api-docs
swagger: '2.0'
paths: {}
basePath: '/'
info:
title: 'Health Insurance System API'
version: '1.0.0'
description: |
System for storing beneficiaries' health insurance information for the
Third-Party Liability group. Update active coverage or query the Carrier
Code Master File.
Describe the bug you’re encountering
Newlines in the description fields are being converted to <br>
. Since these fields should be treated as markdown, single newlines should be converted to an empty space. Double newlines would be converted to <p>
.
For example:
System for storing beneficiaries' health insurance information for the\nThird-Party Liability group.
is being converted to System for storing beneficiaries' health insurance information for the <br> Third-Party Liability group.
To reproduce…
Steps to reproduce the behavior:
- Enter a description with a linebreak.
- Render with SwaggerUI
Expected behavior
Linebreaks are converted to spaces. Contiguous lines are combined in a single <p>
.
Screenshots
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to Convert Line Breaks to HTML <br>
Solved: Hello All. I am building a block schedule request form that uses Power Automate to send the Approval request then replies to...
Read more >Rails: Converting a text field's linebreaks into <br />
I have a text field in my model called 'about', which I'm trying to display on a show page, but none of the...
Read more >How to add a line break to the description field o... - ServiceNow
For this catalog item I am working on, for the description they want essentially multiple sentences to be showing on their own with...
Read more >Line breaks in the message are converted to <br ... - Drupal
I would expect the module to either A) convert newlines to br tags and allow them in the HTML, or B) leave the...
Read more >Text (plain, long) automatically has line break converted to <br>
Since you are using a custom template, the quicker way is just to use the replace() filter. {{ content.field_testing|replace({'<br>': '' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the details, @shockey Note that multiple Markdown paragraphs (when using
>-
) are rendered by Swagger UI with<br>
; I think this is incorrect behavior (though not exactly what the OP cited when using|
instead of>-
):is converted to
not as the expected
Changing this over to a bug 😄
We’ve opted into this behavior:
https://github.com/swagger-api/swagger-ui/blob/b9b4ab20af9d369e02baec3585412fd11ce4bf27/src/core/components/providers/markdown.jsx#L21
Per Remarkable’s docs:
Disabling this does get rid of the breaks seen in the test definition provided by @adborden.