-
Notifications
You must be signed in to change notification settings - Fork 6k
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Boolean body parameters are not sent when false
#5847
Comments
@advance512 What does the HTTP request payload look like? I wonder if your definition using body parameters with just a boolean type is correct. Do you mean to use Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object |
Hey @wing328, Thanks for the reply. What do you mean by "correct definition"? Is the definition not a valid definition of Swagger? The body is empty, so there is nothing to show. |
If the HTTP request body is empty, why do you need to define a body parameter in your OpenAPI spec? |
@wing328 As I understand, @advance512 wants to have a body of either |
@advance512 Without the HTTP request, it would be not easy to understand the problem. Please provide an example so that we can help you out. |
There are two types of HTTP requests made: If the parameter is If the parameter is You'd expect case 1 to have 'Content-Length' set to 5, and the body to be: |
@wing328 |
@wing328 |
FYI, this was fixed in: |
Description
When a body parameter is of type
boolean
and isfalse
, then parameter does not get sent to the server.Swagger-codegen version
2.2.2
Swagger declaration file content or url
Example parameter:
If
approved
is set astrue
, then the call works perfectly. Otherwise, it fails, since the code (inApiClient.js
in the functioncallApi
) contains the following:Of course,
bodyParam
isfalse
, so it is not sent.Command line used for generation
Steps to reproduce
Use this Swagger definition:
and see the generated call. Try to use it with both
approved
astrue
and asfalse
.Related issues
Could not find.
Suggest a Fix
If there is a body parameter defined in the swagger definition, always send it. Except, perhaps, if it is
undefined
.The text was updated successfully, but these errors were encountered: