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

getFormData causes issue in submitting files #1989

Open
tidaldp opened this issue Jan 17, 2024 · 1 comment
Open

getFormData causes issue in submitting files #1989

tidaldp opened this issue Jan 17, 2024 · 1 comment

Comments

@tidaldp
Copy link

tidaldp commented Jan 17, 2024

We're using openapi-typescript-codegen on a project and one of our PUT endpoints has the following requestBody spec:

"requestBody": {
    "content": {
        "multipart/form-data": {
            "schema": {
                "required": [
                    "file"
                ],
                "type": "object",
                "properties": {
                    "file": {
                        "type": "string",
                        "format": "binary"
                    }
                }
            }
        }
    }
},

We use axios and generate a formData object to pass a file on the request like so:

import FormData from 'form-data';

const formData = new FormData();
formData.append('file', <file buffer>, <file name>);

The getFormData code intercepts this and creates a new formData object that axios attempts to use, but it throws an error trying to read the name of the file. Over-riding this code to simply return options.formData resolves this. It's not really clear why getFormData is manipulating the inbound formData object in the first place, is this necessary?

@jordanshatford
Copy link

Check out our fork of this repository @hey-api/openapi-ts. We have fixed this issue in v0.32.1. If you run into any further issues, open an issue in our repository. Thanks.

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

No branches or pull requests

2 participants