Skip to content

[BUG][ANGULAR] Typescript compiler error when using formData #2147

@rolandbaettig

Description

@rolandbaettig
Description

Following api-definition leads to a typscript compiler error

  /document/upload:
    post:
      tags:
        - document
      summary: 'uploads a pdf as a document'
      consumes:
        - multipart/form-data
      parameters:
        - in: formData
          name: file
          type: file
          description: 'The file to upload.'
      responses:
        200:
          description: 'Successful operation'

this generates in the angular service following code (snippet):

        if (file !== undefined) {
            formParams = formParams.append('file', <any>file) || formParams;
        }

which leads to following typscript error:

ERROR in src/app/core/services/backend-api/generated/api/document.service.ts(447,26): error TS1345: An expression of type 'void' cannot be tested for truthiness

openapi-generator version

3.3.4

OpenAPI declaration file content or url
  /document/upload:
    post:
      tags:
        - document
      summary: 'uploads a pdf as a document'
      consumes:
        - multipart/form-data
      parameters:
        - in: formData
          name: file
          type: file
          description: 'The file to upload.'
      responses:
        200:
          description: 'Successful operation'
        405:
          description: 'Invalid input'
Command line used for generation

maven-plugin

Suggest a fix
        if (file !== undefined) {
            formParams = formParams.append('file', <any>file) as any || formParams;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions