Escaped newlines "\n" in example strings converted to "\\" in curl
See original GitHub issueFrom @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
Additional context or thoughts
Copied from original issue: swagger-api/swagger-editor#1880
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
That could be because it’s not been fixed yet. PRs are welcome.