swagger-api / swagger-api/swagger-ui

Vertical bar character | is not escaped in cURL (CMD) request snipped body

Open
#10,540 2 comments 0 reactions 1 assignee View on GitHub

@Divyanshu-Mishra9620 is already working on this.

Since Oct 8, 2025.

Good first issue P3 pull-request-welcome type: bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Windows 11
  • Browser: chrome
  • Version: 138.0.7204.169
  • Method of installation: springdoc-openapi
  • Swagger-UI version: 5.21.0
  • Swagger/OpenAPI version: Swagger 2.2.30, OpenAPI 3.0
Content & configuration

Swagger-UI configuration options (request snippets enabled):

requestSnippetsEnabled: true
Describe the bug you're encountering

The vertical bar character | in the cURL (CMD) request body of the request snippet is not escaped. When running the generated CMD command, the first string after the | is considered a command.

To reproduce...

Steps to reproduce the behavior:

  1. Enable request snippets
  2. Construct a "Try it out" request with a JSON request body having the vertical bar/pipe character |
  3. Execute the request and copy the generated cURL (CMD) snippet into a Windows cmd.exe
  4. The | character is not escaped which leads to a 'some-string' is not recognized as an internal or external command, operable program or batch file. error message in CMD
Expected behavior

The vertical bar character | in the request body of CMD curl snippets is escaped (with a caret ^)

Screenshots

Not escaped | in request body:
Image
Image

Escaped | in request body:
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.