saga
saga

Reputation: 2113

Multiline strings in swagger editor

If I paste the following spec in editor.swagger.io:

openapi: 3.0.0
info:
  title: Callback Example
  version: 1.0.0
paths:
  /streams:
    post:
      description: |
        first line
        second line
        third line
      responses:
        '201':
          description: subscription successfully created
          content:
            application/json:
              schema:
                description: subscription information
                required:
                  - subscriptionId
                properties:
                  subscriptionId:
                    description: this unique identifier allows management of the subscription
                    type: string
                    example: 2531329f-fb09-4ef7-887e-84e648214436

The description is rendered on a single line:

first line second line third line

Even though the yaml spec states that block style strings preserve newlines: https://yaml-multiline.info/

How do I use multiline strings in swagger editor?

Upvotes: 7

Views: 7858

Answers (2)

You can use one of the below-mentioned solutions to get multiline in swagger.

Solution 1:

description: |
  first line \
  second line \
  third line

enter image description here

Solution 2:

description: |
  first line <br>
  second line <br>
  third line

enter image description here

Upvotes: 7

Zsolt Normann
Zsolt Normann

Reputation: 167

You could try using the br tag in the following way:

  description: |
    First line. <br> Second line.<br> Third line

Or this also works:

  description: First line. <br> Second line.<br> Third line

Upvotes: 0

Related Questions