question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
renannpradocommented, Jan 8, 2020

Sometimes things have side effects and this could have been fixed already even if it was not by intention. My intention was to point out that this is not the case, in case someone is looking for an upgrade hoping that this problem won’t appear.

1reaction
webroncommented, Jan 8, 2020

That could be because it’s not been fixed yet. PRs are welcome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Escaped newlines "\n" in example strings converted to "\\" in curl
Refer to the image below, the Curl example seems to be gaining extra backslashes and the n characters are removed. Expected behavior. The...
Read more >
How to send line break with curl? - Stack Overflow
To use it, start the string with $' and end the string with ' : curl -X PUT -d $'my message\n' http://localhost:8000/hello.
Read more >
Issue passing newline `\n` character to curl command
As an example, the following would create a dir named one nesting dir two. echo 'one/two' | xargs mkdir -p same as ->...
Read more >
The string data type - Azure Data Explorer | Microsoft Learn
The backslash is used to escape the enclosing quote characters, tab characters ( \t ), newline characters ( \n ), and itself (...
Read more >
remove line break using AWK - linux - Server Fault
I have manage to replace the spacing into plus symbols.But whenever there is new line,it will have spacing rather than having plus symbol....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found