Skip to content

Escaped newlines "\n" in example strings converted to "\\" in curl #1880

@vmorris

Description

@vmorris

Q&A

  • OS: Linux (RHEL / gnome 3)
  • Browser: chrome
  • Version: 68.0.3440.106
  • Method of installation: docker hub tag 5cb1ec8b71d7
  • Swagger-Editor version: 3.6.10
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.0
servers:
  - url: 'https://{host}/{basePath}'
    variables:
      host:
        default: 0.0.0.0
      basePath:
        default: api
info:
  title: Example
  version: 1.0.0
paths:
  /repositories:
    post:
      summary: Register one repository
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Repository'
      responses:
        '200':
          description: OK
          content:
            application/json: {}
      security:
        - bearerAuth: []
components:
  schemas:
    Repository:
      type: object
      properties:
        repository_id:
          type: string
          description: repository id
        definition:
          type: string
          description: PGP message
      example:
        repoistory_id: example_repo
        definiton: "-----BEGIN PGP MESSAGE-----\nVersion: GnuPG v1\n\nBLAHBLAHBLAH\n-----END PGP MESSAGE-----\n"
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  links: {}
  callbacks: {}
security: []

Swagger-Editor configuration options:
n/a

Describe the bug you're encountering

Refer to the image below, the Curl example seems to be gaining extra backslashes and the n characters are removed.

Expected behavior

The curl command is generated appropriately.

Screenshots

image

Additional context or thoughts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions