forked from loafle/openapi-generator-original
[C++] [cpp-rest-sdk] Check for null values (#990)
* Check whether a value is present but null * Update Petstore sample
This commit is contained in:
committed by
William Cheng
parent
6a1e560540
commit
2d99836e90
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -82,14 +82,19 @@ void Pet::fromJson(web::json::value& val)
|
||||
{
|
||||
if(val.has_field(utility::conversions::to_string_t("id")))
|
||||
{
|
||||
setId(ModelBase::int64_tFromJson(val[utility::conversions::to_string_t("id")]));
|
||||
web::json::value& fieldValue = val[utility::conversions::to_string_t("id")];
|
||||
if(!fieldValue.is_null())
|
||||
{
|
||||
setId(ModelBase::int64_tFromJson(fieldValue));
|
||||
}
|
||||
}
|
||||
if(val.has_field(utility::conversions::to_string_t("category")))
|
||||
{
|
||||
if(!val[utility::conversions::to_string_t("category")].is_null())
|
||||
web::json::value& fieldValue = val[utility::conversions::to_string_t("category")];
|
||||
if(!fieldValue.is_null())
|
||||
{
|
||||
std::shared_ptr<Category> newItem(new Category());
|
||||
newItem->fromJson(val[utility::conversions::to_string_t("category")]);
|
||||
newItem->fromJson(fieldValue);
|
||||
setCategory( newItem );
|
||||
}
|
||||
}
|
||||
@@ -124,7 +129,11 @@ void Pet::fromJson(web::json::value& val)
|
||||
}
|
||||
if(val.has_field(utility::conversions::to_string_t("status")))
|
||||
{
|
||||
setStatus(ModelBase::stringFromJson(val[utility::conversions::to_string_t("status")]));
|
||||
web::json::value& fieldValue = val[utility::conversions::to_string_t("status")];
|
||||
if(!fieldValue.is_null())
|
||||
{
|
||||
setStatus(ModelBase::stringFromJson(fieldValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user