[CppRest] Overload toJson for bool value in ModelBase
Description
We have CppRest client code used in CPP service and this service occasionally communicate to java service.
So when we generate response from rest call, the generated validationResults JSON representation shows status value as 0/1, which creates issue when consumed by java service.
Wondering if we can add option to produce true/false or stick it as default.
Swagger-codegen version
2.2.3-SNAPSHOT
Swagger declaration file content or url
ValidationResult:
description: Validation response contains status
properties:
status:
type: boolean
Command line used for generation
$ java -jar swagger-codegen-cli.jar generate -i validation.yaml -l cpprest -o validation-client
Steps to reproduce
Generate with command give above
Related issues
Suggest a Fix
Not sure if there is any command line option to do this but after looking at swagger-codegen/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache it seems like if we overload toJson for bool will resolve this issue.
web::json::value ModelBase::toJson( bool value )
{
return web::json::value::boolean(value);
}
I am not sure if this will cause any issue to others if we add it as default and If thats the case then we can have some command line option and add as conditional block.
@ravinikam thanks for reporting the issue. I wonder if you can submit a PR with the fix so that we can review.
@wing328 yes will do that, thanks.
Closed via #5448
@wing328 Thanks for merge!