swagger-api / swagger-api/swagger-ui

Modify curlify through the Plugin system?

Open
#4,143 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: plugins type: enhancement
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

First of all I would like to particularly thank you for the well thought design. In particular the Plugin System is really simple and a clever way to provide customization.

Explaining my issue, for a problematic endpoint on my definition I have to send multi-line text/plain on the body. In the code, curlify.js sanitizes the body removing newlines:

if ( request.get("body") ){
    if(type === "multipart/form-data" && request.get("method") === "POST") {
      // ...
    } else {
      curlified.push( "-d" )
      curlified.push( JSON.stringify( request.get("body") ).replace(/\\n/g, "") )
    }
}

But I would like to send the body as is and add "$" for curl to process it properly:

if ( request.get("body") ){
    if(type === "multipart/form-data" && request.get("method") === "POST") {
      // ...
    } else {
      curlified.push( "-d" )
      if(type === "text/plain") {
        curlified.push( "$" )
        curlified.push( request.get("body") )
      } else
        curlified.push( JSON.stringify( request.get("body") ).replace(/\\n/g, "") )
    }
}

@shockey
Can I achieve this through the plugin system? Or maybe the change qualifies as a pull-request?

Thanks in advance for your care and patience!

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.

Research direction

Start by reading curlify.js and the Plugin System documentation or entry points mentioned in the issue. Verify how text/plain request bodies are converted into curl arguments, then confirm that multiline text/plain bodies are preserved while other body types retain their current behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.