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 842571dcbef..2959ee7c9e4 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 105bb87d77b..6d94c9c2e12 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 32a7e44548c..9b7ae17bd82 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 2381ce335a3..0ce3eeb4916 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 292054f38e6..95a6c5fc1b9 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 c6dde17bc8c..218c92b403f 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 150d30bbd2c..f1eb81c2144 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 517313c47f5..4958f09ad74 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 7c7ac5840ba..3f94dd84a97 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 864ec2075e6..9cc76d8d114 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 dc9bc6f089c..c5e173490f7 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 c2f9c451061..276f83abbb2 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 3f5702dfb88..ada2e9eb11b 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 c0ef13e4ac2..10bffc4d1fa 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 8c2a0d80a00..2eedce34bf1 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 b1cd75ded0e..af977862526 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 6542845bcc1..3cc52c4990c 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 42694b488ed..c732027e2ac 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 a8f58b43a97..0914c1fd7c1 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 8d99e86ca8a..eb912354ea0 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 e63710124ca..ae7546f1150 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 c690f2be511..55cfb7850e9 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 f952506a16d..6380402473e 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 af3fb210b68..24376a87477 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 d74deecb3d0..2afa0af9281 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 b93cbb85328..ce86c5523e4 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 fc1bf4e6109..2c257ab297b 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 53494010800..c39bf76fc8b 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 ab370a4bb03..87f4224b2ab 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 7f5b5464d5f..fe2ecb8ebe9 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 b2d4410d643..1b3b7f1e121 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 78fed60be7d..ac8c2232b2d 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 c4e0d0b4978..a0d457cabac 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 8c0c537cf26..416ec5e2de5 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 b2b49f58c43..d78e2c34001 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 511811b9f08..d8ec0c8c437 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 aca144de933..01c3271f934 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. */