swagger-api/swagger-ui

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

Open

#4,871 opened on Sep 13, 2018

View on GitHub
 (6 comments) (1 reaction) (0 assignees)JavaScript (8,801 forks)batch import
Hacktoberfestcat: try-it-outtype: bug

Repository metrics

Stars
 (25,447 stars)
PR merge metrics
 (Avg merge 20h 34m) (14 merged PRs in 30d)

Description

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

Contributor guide