[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.