title: OpenAPI Generator typescript-axios multipart/form-data How to Use Generated Function
body: <p>I have a valid OpenAPI spec for a form with <code>multipart/form-data</code> containing a file and an additional text field.
  (<a href="http://stackoverflow.com/questions/65082784">generated from NestJS-Swagger, documented here</a>)</p>
  <p>It works from the Swagger UI, but I cannot figure out how to get the API code generated by the OpenAPI Generator for <code>typescript-axios</code> to work.</p>
  <p>Here is the OpenAPI YAML</p>
  <pre class="lang-yaml prettyprint-override"><code>&quot;/users/files&quot;:
    post:
      operationId: UsersController_addPrivateFile
      summary: &quot;...&quot;
      parameters: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              &quot;$ref&quot;: &quot;#/components/schemas/UploadFileDto&quot;
  </code></pre>
  <p>...</p>
  <pre class="lang-yaml prettyprint-override"><code>UploadFileDto:
    type: object
    properties:
      file:
        type: file
        properties:
          file:
            type: string
            format: binary
        description: &quot;...&quot;
        example: &quot;'file': &lt;any-kind-of-binary-file&gt;&quot;
      user_id:
        type: string
        description: &quot;...&quot;
        example: cus_IPqRS333voIGbS
    required:
    - file
    - user_id
  </code></pre>
  <p>here is what it looks like working in Swagger UI</p>
  <p><a href="https://i.stack.imgur.com/VSmwJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VSmwJ.png" alt="working swagger docs for multipart form data with additional form field" /></a></p>
  <p>The Axios Output seems to respect the API (I've ellipsed non-related parts of these functions</p>
  <pre class="lang-js prettyprint-override"><code>public usersControllerAddPrivateFile(file: object, userId: string) {
      return UsersApiFp(this.configuration)
          .usersControllerAddPrivateFile(file, userId)
          .then((request) =&gt; request(this.axios, this.basePath));
  }
  
  async usersControllerAddPrivateFile(file, userId){
      const localVarAxiosArgs = await UsersApiAxiosParamCreator(
          configuration,
      ).usersControllerAddPrivateFile(file, userId);
      return (...) =&gt; {
          const axiosRequestArgs = {
              ...localVarAxiosArgs.options,
              ...
          };
          return axios.request(axiosRequestArgs);
      };
  }
  
  usersControllerAddPrivateFile(file, userId){
      ...
      const localVarFormParams = new FormData();
      localVarFormParams.append('file', file as any);
      localVarFormParams.append('user_id', userId as any);
      localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
      ...
  }
  </code></pre>
  <p>I'm calling the function like this</p>
  <pre class="lang-js prettyprint-override"><code>onFileUpload = () =&gt; {
      const formData = new FormData();
      formData.append('file', this.state.selectedFile);
      const usersApi = new UsersApi();
      usersApi.usersControllerAddPrivateFile(formData,this.state.data.user_id,);
  };
  </code></pre>
  <p>logging on both client and server show the body is missing...despite the file and the user ID both being present</p>
  <p><a href="https://i.stack.imgur.com/Pvj14.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pvj14.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/YjpJb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YjpJb.png" alt="enter image description here" /></a></p>