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

[Typescript][Angular] formParams are not included as body in the request #9890

Closed
angelfraga opened this issue Nov 25, 2019 · 0 comments
Closed

Comments

@angelfraga
Copy link

Description

The generated code doesn't add formParams as body for files.

Swagger-codegen version

Current online typescript-angular generator.

Swagger declaration file content or url
openapi: 3.0.1
info:
  title: CSV import api 
  version: '1.0'
paths:
  /api/1/Import:
    post:
      tags:
        - CSV
      summary: Import a csv
      operationId: ImportCsv
      parameters:
        - name: X-Correlation-ID
          in: header
          schema:
            type: string
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
            encoding:
              file:
                style: form
      responses:
        '200':
          description: Success
tags:
  - name: CSV
    description: 'Import a csv file'

Produces

       ....
        if (file !== undefined) {
            formParams = formParams.append('file', <any>file) as any || formParams;
        }
       // HERE   
        return this.httpClient.post<any>(`${this.basePath}/api/1/Import`,
            {
                withCredentials: this.configuration.withCredentials,
                headers: headers,
                observe: observe,
                reportProgress: reportProgress
            }
        );
       ....

Instead of

       ....
        if (file !== undefined) {
            formParams = formParams.append('file', <any>file) as any || formParams;
        }
        return this.httpClient.post<any>(`${this.basePath}/api/1/Import`,
            formParams, // as body
            {
                withCredentials: this.configuration.withCredentials,
                headers: headers,
                observe: observe,
                reportProgress: reportProgress
            }
        );
       ....
Command line used for generation

Online generator.

@angelfraga angelfraga changed the title [Typescript][Angular] formParams are notbeing include as body in the request [Typescript][Angular] formParams are included as body in the request Nov 25, 2019
@angelfraga angelfraga changed the title [Typescript][Angular] formParams are included as body in the request [Typescript][Angular] formParams are not included as body in the request Nov 25, 2019
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

1 participant