BODY_DTO fails to correctly parse "false" for Boolean
Observing some strange behavior when trying to parse a body dto for an endpoint which contains a single boolean value. Value is correctly parsed when equal to true, but fails when equal to false. Wondering if this is related to 673.
Issue is reproducible with a controller w/ the following structure:
ENDPOINT("PUT", "/set_flag", setFlag, BODY_DTO(Boolean, aBool))
{
std::cout << "param = " << *aBool << std::endl;
return createResponse(Status::CODE_200, "OK");
}
When sending a request to this endpoint w/ a request body of "false", a 400 error is generated. When sending a request w/ a request body of "true", the boolean is correctly parsed.
I'm suspicious of the following section:
https://github.com/oatpp/oatpp/blob/57e6a714d757d3fcc85214bc59011f01bbdb1cc4/src/oatpp/codegen/api_controller/base_define.hpp#L243-L245
Suspect that check should compare to nullptr similar to fix for 673.
When modifying the body parameter check mentioned above to the following:
if(OATPP_MACRO_FIRSTARG PARAM_LIST != nullptr) {
throw oatpp::web::protocol::http::HttpError(Status::CODE_400, "Missing valid body parameter '" OATPP_MACRO_FIRSTARG_STR PARAM_LIST "'");
}
I noticed I also needed to declare one of the operator!= definitions as const in the base DTOWrapper class:
https://github.com/oatpp/oatpp/blob/57e6a714d757d3fcc85214bc59011f01bbdb1cc4/src/oatpp/core/data/mapping/type/Object.hpp#L357-L369
I suspect this is because the variable specified in the BODY_DTO macro has a const modifier:
https://github.com/oatpp/oatpp/blob/57e6a714d757d3fcc85214bc59011f01bbdb1cc4/src/oatpp/codegen/api_controller/base_define.hpp#L241-L242
Couldn't think of a reason why making this method const would break anything and suspect it may need to be part of a fix for this issue.