Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQ] [Bash] Allow non-JSON request body payloads #17634

Open
mHejlesen opened this issue Jan 17, 2024 · 2 comments
Open

[REQ] [Bash] Allow non-JSON request body payloads #17634

mHejlesen opened this issue Jan 17, 2024 · 2 comments

Comments

@mHejlesen
Copy link
Contributor

Is your feature request related to a problem? Please describe.

A generated bash client can only send JSON objects, not JSON arrays or ordinary string payloads.

Example:
Creating the following operation with a request body requiring a non-JSON string:

{
  "put": {
    "operationId": "bar",
    "parameters": [
    ],
    "requestBody": {
      "description": "String to be parsed",
      "content": {
        "application/json": {
          "schema": {
            "type": "string"
          }
        }
      },
      "required": true
    }
  }
}

On the server I would like to receive the raw string:

 @PUT
 public void bar(String body) {
    System.out.println("Request body: " + body);
  }

At the time of writing my only option is to write the payload to a file or send it as JSON:

./client.sh --host http://localhost:8080 bar body==hello

The above results in the JSON blob:
{"body": "hello world"}

Describe the solution you'd like

I would like to instead write:
./client.sh --host http://localhost:8080 bar --body=hello

And receive the string: hello

Describe alternatives you've considered

I have considered a file with the payload but it is very awkward and cumbersome to use.

@wing328
Copy link
Member

wing328 commented Jan 17, 2024

A generated bash client can only send JSON objects, not JSON arrays or ordinary string payloads.

agreed with that.

Is that something you can contribute? we can show you some good starting points.

@mHejlesen
Copy link
Contributor Author

Yes.
I have made a local change that achieves the described solution and I will make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants