redoc icon indicating copy to clipboard operation
redoc copied to clipboard

Multiline string examples render wrong

Open tomgreen98 opened this issue 5 years ago • 2 comments

If a string example includes \n (newline) characters, these are not honored when rendering examples.

Say you have a parameter like this:

        parameters:
        - description: The contents of the `php.ini` file.
          in: query
          name: content
          schema:
            example: |
              [PHP]
              ; About php.ini
              ; php.ini is responsible for configuring many of the aspects of PHP's behavior.
              pcre.backtrack_limit=100000
            type: string

The Example printed to the output places the example on lines ignoring the \n characters.

current

Where as I would have expected something similar to:

desired

tomgreen98 avatar Sep 15 '20 13:09 tomgreen98

Has this issue been fixed? I'm running into it too.

albsinger avatar Oct 04 '22 18:10 albsinger

~~I have the same problem, and as a workaround, I'm using </br> instead to get around it.~~

Use \\\n instead of \n.

@doc("Hello\\\nWorld")
hoge: |
  Hello \
  World

Kyome22 avatar Nov 25 '25 04:11 Kyome22