Skip to content

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

@shockey

Description

@shockey

From @vmorris on September 13, 2018 0:21

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

Copied from original issue: swagger-api/swagger-editor#1880

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions