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
  • #1432
Closed
Open
Issue created Nov 13, 2018 by Administrator@rootContributor

[JavaScript] Boolean body parameters are not sent when `false`

Created by: advance512

Description

When a body parameter is of type boolean and is false, then parameter does not get sent to the server.

Version

openapi-generator-cli-3.3.3-20181113.090410-41.jar

Swagger declaration file content or url

Example parameter:

      parameters:
        - name: approved
          in: body
          required: true
          description: Whether to approve or disapprove the entity.
          schema:
            type: boolean

If approved is set as true, then the call works perfectly. Otherwise, it fails, since the code (in ApiClient.js in the function callApi) contains the following:

    } else if (bodyParam) {
      request.send(bodyParam);
    }

Of course, bodyParam is false, so it is not sent.

Command line used for generation
java -jar openapi-generator-cli-3.3.3-20181113.090410-41.jar generate -i ../swagger.yaml -l javascript --additional-properties usePromises=true
Steps to reproduce

Use this Swagger definition:

  /approve:

    post:
      parameters:
        - name: approved
          in: body
          required: true
          schema:
            type: boolean

and see the generated call. Try to use it with both approved as true and as false.

Related issues

This is a similar issue in swagger-codegen, with more information: https://github.com/swagger-api/swagger-codegen/issues/5847

Suggest a Fix

If there is a body parameter defined in the swagger definition, always send it. Except, perhaps, if it is undefined.

Assignee
Assign to
Time tracking