Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2147
Closed
Open
Issue created Feb 13, 2019 by Administrator@rootContributor

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

Created by: 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;
        }
Assignee
Assign to
Time tracking