swagger-api / swagger-api/swagger-ui
Escaped newlines "\n" in example strings converted to "\\" in curl
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
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

Additional context or thoughts
Copied from original issue: swagger-api/swagger-editor#1880
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the OpenAPI example in the report and inspect the generated curl command in Swagger UI. Trace the curl-generation entry point to see where escaped newlines are transformed; done means the command preserves the intended newlines and the reported example behaves as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100