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

[JavaScript] Boolean body parameters are not sent when false #1432

Closed
advance512 opened this issue Nov 13, 2018 · 0 comments · Fixed by #1515
Closed

[JavaScript] Boolean body parameters are not sent when false #1432

advance512 opened this issue Nov 13, 2018 · 0 comments · Fixed by #1515

Comments

@advance512
Copy link

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:
swagger-api/swagger-codegen#5847

Suggest a Fix

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants