From 2d99836e9047d74e958910aca1aa38b34e584daa Mon Sep 17 00:00:00 2001 From: Juan Eugenio Abadie Date: Mon, 10 Sep 2018 13:15:44 -0300 Subject: [PATCH] [C++] [cpp-rest-sdk] Check for null values (#990) * Check whether a value is present but null * Update Petstore sample --- .../cpp-rest-sdk-client/model-source.mustache | 41 ++++++++------- .../cpp-restsdk/.openapi-generator/VERSION | 2 +- .../client/petstore/cpp-restsdk/ApiClient.cpp | 2 +- .../client/petstore/cpp-restsdk/ApiClient.h | 2 +- .../petstore/cpp-restsdk/ApiConfiguration.cpp | 2 +- .../petstore/cpp-restsdk/ApiConfiguration.h | 2 +- .../petstore/cpp-restsdk/ApiException.cpp | 2 +- .../petstore/cpp-restsdk/ApiException.h | 2 +- .../petstore/cpp-restsdk/HttpContent.cpp | 2 +- .../client/petstore/cpp-restsdk/HttpContent.h | 2 +- .../client/petstore/cpp-restsdk/IHttpBody.h | 2 +- .../client/petstore/cpp-restsdk/JsonBody.cpp | 2 +- .../client/petstore/cpp-restsdk/JsonBody.h | 2 +- .../client/petstore/cpp-restsdk/ModelBase.cpp | 2 +- .../client/petstore/cpp-restsdk/ModelBase.h | 2 +- .../cpp-restsdk/MultipartFormData.cpp | 2 +- .../petstore/cpp-restsdk/MultipartFormData.h | 2 +- .../client/petstore/cpp-restsdk/Object.cpp | 2 +- samples/client/petstore/cpp-restsdk/Object.h | 2 +- .../petstore/cpp-restsdk/api/PetApi.cpp | 2 +- .../client/petstore/cpp-restsdk/api/PetApi.h | 2 +- .../petstore/cpp-restsdk/api/StoreApi.cpp | 2 +- .../petstore/cpp-restsdk/api/StoreApi.h | 2 +- .../petstore/cpp-restsdk/api/UserApi.cpp | 2 +- .../client/petstore/cpp-restsdk/api/UserApi.h | 2 +- .../cpp-restsdk/model/ApiResponse.cpp | 20 ++++++-- .../petstore/cpp-restsdk/model/ApiResponse.h | 2 +- .../petstore/cpp-restsdk/model/Category.cpp | 14 ++++-- .../petstore/cpp-restsdk/model/Category.h | 2 +- .../petstore/cpp-restsdk/model/Order.cpp | 38 +++++++++++--- .../client/petstore/cpp-restsdk/model/Order.h | 2 +- .../client/petstore/cpp-restsdk/model/Pet.cpp | 19 +++++-- .../client/petstore/cpp-restsdk/model/Pet.h | 2 +- .../client/petstore/cpp-restsdk/model/Tag.cpp | 14 ++++-- .../client/petstore/cpp-restsdk/model/Tag.h | 2 +- .../petstore/cpp-restsdk/model/User.cpp | 50 +++++++++++++++---- .../client/petstore/cpp-restsdk/model/User.h | 2 +- 37 files changed, 177 insertions(+), 79 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache index 842571dcbefb..2959ee7c9e43 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache @@ -140,7 +140,11 @@ void {{classname}}::fromJson(web::json::value& val) {{^required}} if(val.has_field(utility::conversions::to_string_t("{{baseName}}"))) { - {{setter}}(ModelBase::{{baseType}}FromJson(val[utility::conversions::to_string_t("{{baseName}}")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("{{baseName}}")]; + if(!fieldValue.is_null()) + { + {{setter}}(ModelBase::{{baseType}}FromJson(fieldValue)); + } } {{/required}} {{#required}} @@ -242,27 +246,28 @@ void {{classname}}::fromJson(web::json::value& val) {{^required}} if(val.has_field(utility::conversions::to_string_t("{{baseName}}"))) { - {{#isString}} - {{setter}}(ModelBase::stringFromJson(val[utility::conversions::to_string_t("{{baseName}}")])); - {{/isString}} - {{#isByteArray}} - {{setter}}(ModelBase::stringFromJson(val[utility::conversions::to_string_t("{{baseName}}")])); - {{/isByteArray}} - {{^isString}} - {{#isDateTime}} - {{setter}}(ModelBase::dateFromJson(val[utility::conversions::to_string_t("{{baseName}}")])); - {{/isDateTime}} - {{^isDateTime}} - {{^isByteArray}} - if(!val[utility::conversions::to_string_t("{{baseName}}")].is_null()) + web::json::value& fieldValue = val[utility::conversions::to_string_t("{{baseName}}")]; + if(!fieldValue.is_null()) { + {{#isString}} + {{setter}}(ModelBase::stringFromJson(fieldValue)); + {{/isString}} + {{#isByteArray}} + {{setter}}(ModelBase::stringFromJson(fieldValue)); + {{/isByteArray}} + {{^isString}} + {{#isDateTime}} + {{setter}}(ModelBase::dateFromJson(fieldValue)); + {{/isDateTime}} + {{^isDateTime}} + {{^isByteArray}} {{{dataType}}} newItem({{{defaultValue}}}); - newItem->fromJson(val[utility::conversions::to_string_t("{{baseName}}")]); + newItem->fromJson(fieldValue); {{setter}}( newItem ); + {{/isByteArray}} + {{/isDateTime}} + {{/isString}} } - {{/isByteArray}} - {{/isDateTime}} - {{/isString}} } {{/required}} {{#required}} diff --git a/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION b/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION index 105bb87d77b3..6d94c9c2e12a 100644 --- a/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION +++ b/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.2-SNAPSHOT \ No newline at end of file +3.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.cpp b/samples/client/petstore/cpp-restsdk/ApiClient.cpp index 32a7e44548c5..9b7ae17bd823 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiClient.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.h b/samples/client/petstore/cpp-restsdk/ApiClient.h index 2381ce335a38..0ce3eeb49165 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.h +++ b/samples/client/petstore/cpp-restsdk/ApiClient.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp index 292054f38e69..95a6c5fc1b95 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h index c6dde17bc8c6..218c92b403f5 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.cpp b/samples/client/petstore/cpp-restsdk/ApiException.cpp index 150d30bbd2ce..f1eb81c21447 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiException.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.h b/samples/client/petstore/cpp-restsdk/ApiException.h index 517313c47f51..4958f09ad74f 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.h +++ b/samples/client/petstore/cpp-restsdk/ApiException.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.cpp b/samples/client/petstore/cpp-restsdk/HttpContent.cpp index 7c7ac5840ba6..3f94dd84a97b 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.cpp +++ b/samples/client/petstore/cpp-restsdk/HttpContent.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.h b/samples/client/petstore/cpp-restsdk/HttpContent.h index 864ec2075e63..9cc76d8d1144 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.h +++ b/samples/client/petstore/cpp-restsdk/HttpContent.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/IHttpBody.h b/samples/client/petstore/cpp-restsdk/IHttpBody.h index dc9bc6f089c2..c5e173490f7b 100644 --- a/samples/client/petstore/cpp-restsdk/IHttpBody.h +++ b/samples/client/petstore/cpp-restsdk/IHttpBody.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.cpp b/samples/client/petstore/cpp-restsdk/JsonBody.cpp index c2f9c451061f..276f83abbb2a 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.cpp +++ b/samples/client/petstore/cpp-restsdk/JsonBody.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.h b/samples/client/petstore/cpp-restsdk/JsonBody.h index 3f5702dfb882..ada2e9eb11ba 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.h +++ b/samples/client/petstore/cpp-restsdk/JsonBody.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.cpp b/samples/client/petstore/cpp-restsdk/ModelBase.cpp index c0ef13e4ac24..10bffc4d1fa4 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.cpp +++ b/samples/client/petstore/cpp-restsdk/ModelBase.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.h b/samples/client/petstore/cpp-restsdk/ModelBase.h index 8c2a0d80a002..2eedce34bf13 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.h +++ b/samples/client/petstore/cpp-restsdk/ModelBase.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp index b1cd75ded0e4..af9778625267 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.h b/samples/client/petstore/cpp-restsdk/MultipartFormData.h index 6542845bcc19..3cc52c4990cf 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.h +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/Object.cpp b/samples/client/petstore/cpp-restsdk/Object.cpp index 42694b488ed4..c732027e2aca 100644 --- a/samples/client/petstore/cpp-restsdk/Object.cpp +++ b/samples/client/petstore/cpp-restsdk/Object.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/Object.h b/samples/client/petstore/cpp-restsdk/Object.h index a8f58b43a972..0914c1fd7c17 100644 --- a/samples/client/petstore/cpp-restsdk/Object.h +++ b/samples/client/petstore/cpp-restsdk/Object.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp index 8d99e86ca8ad..eb912354ea0b 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.h b/samples/client/petstore/cpp-restsdk/api/PetApi.h index e63710124ca7..ae7546f11503 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.h +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp index c690f2be5112..55cfb7850e9c 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.h b/samples/client/petstore/cpp-restsdk/api/StoreApi.h index f952506a16dc..6380402473e9 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.h +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp index af3fb210b684..24376a874774 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.h b/samples/client/petstore/cpp-restsdk/api/UserApi.h index d74deecb3d08..2afa0af92819 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.h +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp index b93cbb85328c..ce86c5523e48 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp @@ -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. */ @@ -61,15 +61,27 @@ void ApiResponse::fromJson(web::json::value& val) { if(val.has_field(utility::conversions::to_string_t("code"))) { - setCode(ModelBase::int32_tFromJson(val[utility::conversions::to_string_t("code")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("code")]; + if(!fieldValue.is_null()) + { + setCode(ModelBase::int32_tFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("type"))) { - setType(ModelBase::stringFromJson(val[utility::conversions::to_string_t("type")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("type")]; + if(!fieldValue.is_null()) + { + setType(ModelBase::stringFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("message"))) { - setMessage(ModelBase::stringFromJson(val[utility::conversions::to_string_t("message")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("message")]; + if(!fieldValue.is_null()) + { + setMessage(ModelBase::stringFromJson(fieldValue)); + } } } diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h index fc1bf4e61092..2c257ab297b1 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Category.cpp b/samples/client/petstore/cpp-restsdk/model/Category.cpp index 534940108008..c39bf76fc8b9 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Category.cpp @@ -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. */ @@ -55,11 +55,19 @@ void Category::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("name"))) { - setName(ModelBase::stringFromJson(val[utility::conversions::to_string_t("name")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("name")]; + if(!fieldValue.is_null()) + { + setName(ModelBase::stringFromJson(fieldValue)); + } } } diff --git a/samples/client/petstore/cpp-restsdk/model/Category.h b/samples/client/petstore/cpp-restsdk/model/Category.h index ab370a4bb03c..87f4224b2ab0 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.h +++ b/samples/client/petstore/cpp-restsdk/model/Category.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Order.cpp b/samples/client/petstore/cpp-restsdk/model/Order.cpp index 7f5b5464d5f1..fe2ecb8ebe9d 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Order.cpp @@ -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. */ @@ -79,27 +79,51 @@ void Order::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("petId"))) { - setPetId(ModelBase::int64_tFromJson(val[utility::conversions::to_string_t("petId")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("petId")]; + if(!fieldValue.is_null()) + { + setPetId(ModelBase::int64_tFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("quantity"))) { - setQuantity(ModelBase::int32_tFromJson(val[utility::conversions::to_string_t("quantity")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("quantity")]; + if(!fieldValue.is_null()) + { + setQuantity(ModelBase::int32_tFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("shipDate"))) { - setShipDate(ModelBase::dateFromJson(val[utility::conversions::to_string_t("shipDate")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("shipDate")]; + if(!fieldValue.is_null()) + { + setShipDate(ModelBase::dateFromJson(fieldValue)); + } } 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)); + } } if(val.has_field(utility::conversions::to_string_t("complete"))) { - setComplete(ModelBase::boolFromJson(val[utility::conversions::to_string_t("complete")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("complete")]; + if(!fieldValue.is_null()) + { + setComplete(ModelBase::boolFromJson(fieldValue)); + } } } diff --git a/samples/client/petstore/cpp-restsdk/model/Order.h b/samples/client/petstore/cpp-restsdk/model/Order.h index b2d4410d6436..1b3b7f1e1219 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.h +++ b/samples/client/petstore/cpp-restsdk/model/Order.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/model/Pet.cpp index 78fed60be7d5..ac8c2232b2db 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Pet.cpp @@ -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 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)); + } } } diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.h b/samples/client/petstore/cpp-restsdk/model/Pet.h index c4e0d0b49787..a0d457cabace 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/model/Pet.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.cpp b/samples/client/petstore/cpp-restsdk/model/Tag.cpp index 8c0c537cf260..416ec5e2de59 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Tag.cpp @@ -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. */ @@ -55,11 +55,19 @@ void Tag::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("name"))) { - setName(ModelBase::stringFromJson(val[utility::conversions::to_string_t("name")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("name")]; + if(!fieldValue.is_null()) + { + setName(ModelBase::stringFromJson(fieldValue)); + } } } diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.h b/samples/client/petstore/cpp-restsdk/model/Tag.h index b2b49f58c433..d78e2c34001e 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.h +++ b/samples/client/petstore/cpp-restsdk/model/Tag.h @@ -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. */ diff --git a/samples/client/petstore/cpp-restsdk/model/User.cpp b/samples/client/petstore/cpp-restsdk/model/User.cpp index 511811b9f087..d8ec0c8c4376 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.cpp +++ b/samples/client/petstore/cpp-restsdk/model/User.cpp @@ -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. */ @@ -91,35 +91,67 @@ void User::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("username"))) { - setUsername(ModelBase::stringFromJson(val[utility::conversions::to_string_t("username")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("username")]; + if(!fieldValue.is_null()) + { + setUsername(ModelBase::stringFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("firstName"))) { - setFirstName(ModelBase::stringFromJson(val[utility::conversions::to_string_t("firstName")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("firstName")]; + if(!fieldValue.is_null()) + { + setFirstName(ModelBase::stringFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("lastName"))) { - setLastName(ModelBase::stringFromJson(val[utility::conversions::to_string_t("lastName")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("lastName")]; + if(!fieldValue.is_null()) + { + setLastName(ModelBase::stringFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("email"))) { - setEmail(ModelBase::stringFromJson(val[utility::conversions::to_string_t("email")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("email")]; + if(!fieldValue.is_null()) + { + setEmail(ModelBase::stringFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("password"))) { - setPassword(ModelBase::stringFromJson(val[utility::conversions::to_string_t("password")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("password")]; + if(!fieldValue.is_null()) + { + setPassword(ModelBase::stringFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("phone"))) { - setPhone(ModelBase::stringFromJson(val[utility::conversions::to_string_t("phone")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("phone")]; + if(!fieldValue.is_null()) + { + setPhone(ModelBase::stringFromJson(fieldValue)); + } } if(val.has_field(utility::conversions::to_string_t("userStatus"))) { - setUserStatus(ModelBase::int32_tFromJson(val[utility::conversions::to_string_t("userStatus")])); + web::json::value& fieldValue = val[utility::conversions::to_string_t("userStatus")]; + if(!fieldValue.is_null()) + { + setUserStatus(ModelBase::int32_tFromJson(fieldValue)); + } } } diff --git a/samples/client/petstore/cpp-restsdk/model/User.h b/samples/client/petstore/cpp-restsdk/model/User.h index aca144de9334..01c3271f9347 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.h +++ b/samples/client/petstore/cpp-restsdk/model/User.h @@ -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. */