swagger-api/swagger-ui

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

Open

#4871 aperta il 13 set 2018

Vedi su GitHub
 (6 commenti) (1 reazione) (0 assegnatari)JavaScript (8801 fork)batch import
Hacktoberfestcat: try-it-outtype: bug

Metriche repository

Star
 (25.447 star)
Metriche merge PR
 (Merge medio 20h 34m) (14 PR mergiate in 30 g)

Descrizione

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

Guida contributor