Skip to content

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

@erik-puchinger

Description

@erik-puchinger

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions