[CPPREST] [C++] Required string fields are not handled properly in the cpprest generator
Description
In ModelBase.cpp, the default code generated for stringFromJson() is:
utility::string_t ModelBase::stringFromJson(web::json::value& val) { return val.is_string() ? val.as_string() : U(""); }
As you can see, this supplies an empty string when no value is given.
However, this is a problem if the field is flagged as a required field. If a required string field is missing, instead of getting a 500 Internal error response, the field is given a default value of "" and processed onward.
Swagger-codegen version
Using the new online editor on 13-JUL-2017. 3.x maybe?
Swagger declaration file content or url
ExampleContext:
type: object
required:
- taskName
- examName
properties:
taskName:
type: string
examName:
type: string
Command line used for generation
Steps to reproduce
Related issues
Suggest a Fix
v2.2.3 has been released with many enhancement to C++ (cpprest) generator. Please give that a try.
If it's still an issue, we'll reopen this.
This is still an issue. Please reopen.