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

How to provide request body? #31

Open
JanCizmar opened this issue May 18, 2022 · 5 comments · May be fixed by #50
Open

How to provide request body? #31

JanCizmar opened this issue May 18, 2022 · 5 comments · May be fixed by #50

Comments

@JanCizmar
Copy link

I need to pass formdata for file upload to the request, but there is no documented way how to do that.

@ajaishankar
Copy link
Owner

@JanCizmar only json request body is supported. The main use of the library is for strongly typed request and response...

@JanCizmar
Copy link
Author

The request is strongly typed:

Relevant part of paths interface

  addFiles_1: {
    parameters: {
      query: {
        ak?: string;
      };
    };
    responses: {
      /** OK */
      200: {
        content: {
          "*/*": components["schemas"]["ImportAddFilesResultModel"];
        };
      };
      /** Bad Request */
      400: {
        content: {
          "*/*": string;
        };
      };
      /** Not Found */
      404: {
        content: {
          "*/*": string;
        };
      };
    };
    requestBody: {
      content: {
        "multipart/form-data": {
          files: string[];
        };
      };
    };
  };

So the request body is strictly typed.

@nilsmehlhorn
Copy link

I'm also encountering this use case for endpoints that expect binary bodies. I think this would be achievable by not overriding the body that can be passed via RequesInit with JSON if it's already present. What do you think @ajaishankar ?

voxpelli added a commit to voxpelli/openapi-typescript-fetch that referenced this issue Oct 28, 2022
@voxpelli voxpelli linked a pull request Oct 28, 2022 that will close this issue
@igor-q-bio
Copy link

Is there any update on this issue and the PR #50?

Rendez pushed a commit to Rendez/openapi-typescript-fetch that referenced this issue May 11, 2023
@markmiller21
Copy link

Any movement on this? We're hacking around this bug at the moment (using a fetch as a post request). I would prefer to not switch architecture away from this but I can't tell soundly tell my team to continue in footsteps

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

Successfully merging a pull request may close this issue.

5 participants