Fix issue deserializing to nullptr (#3572)

* Fix issue deserializing to nullptr

* Update codegen files
This commit is contained in:
dan-drl
2019-08-08 09:17:54 -07:00
committed by William Cheng
parent 36dd848440
commit 752030890f
40 changed files with 109 additions and 47 deletions

View File

@@ -359,7 +359,10 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
} else if (ModelUtils.isStringSchema(p)) {
return "utility::conversions::to_string_t(\"\")";
} else if (ModelUtils.isFreeFormObject(p)) {
return "new Object()";
}
return "nullptr";
}

View File

@@ -265,16 +265,19 @@ std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& en
int64_t ModelBase::int64_tFromJson(const web::json::value& val)
{
return val.as_number().to_int64();
return val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
}
int32_t ModelBase::int32_tFromJson(const web::json::value& val)
{
return val.as_integer();
return val.is_null() ? std::numeric_limits<int32_t>::quiet_NaN() : val.as_integer();
}
float ModelBase::floatFromJson(const web::json::value& val)
{
return static_cast<float>(val.as_double());
return val.is_null() ? std::numeric_limits<float>::quiet_NaN() : static_cast<float>(val.as_double());
}
utility::string_t ModelBase::stringFromJson(const web::json::value& val)
{
return val.is_string() ? val.as_string() : utility::conversions::to_string_t("");
@@ -282,15 +285,15 @@ utility::string_t ModelBase::stringFromJson(const web::json::value& val)
utility::datetime ModelBase::dateFromJson(const web::json::value& val)
{
return utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
return val.is_null() ? utility::datetime::from_string(L"NULL", utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
}
bool ModelBase::boolFromJson(const web::json::value& val)
{
return val.as_bool();
return val.is_null() ? false : val.as_bool();
}
double ModelBase::doubleFromJson(const web::json::value& val)
{
return val.as_double();
return val.is_null() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
}
int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val)

View File

@@ -0,0 +1,29 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app

View File

@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@@ -0,0 +1 @@
4.1.0-SNAPSHOT

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@@ -276,16 +276,19 @@ std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& en
int64_t ModelBase::int64_tFromJson(const web::json::value& val)
{
return val.as_number().to_int64();
return val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
}
int32_t ModelBase::int32_tFromJson(const web::json::value& val)
{
return val.as_integer();
return val.is_null() ? std::numeric_limits<int32_t>::quiet_NaN() : val.as_integer();
}
float ModelBase::floatFromJson(const web::json::value& val)
{
return static_cast<float>(val.as_double());
return val.is_null() ? std::numeric_limits<float>::quiet_NaN() : static_cast<float>(val.as_double());
}
utility::string_t ModelBase::stringFromJson(const web::json::value& val)
{
return val.is_string() ? val.as_string() : utility::conversions::to_string_t("");
@@ -293,15 +296,15 @@ utility::string_t ModelBase::stringFromJson(const web::json::value& val)
utility::datetime ModelBase::dateFromJson(const web::json::value& val)
{
return utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
return val.is_null() ? utility::datetime::from_string(L"NULL", utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
}
bool ModelBase::boolFromJson(const web::json::value& val)
{
return val.as_bool();
return val.is_null() ? false : val.as_bool();
}
double ModelBase::doubleFromJson(const web::json::value& val)
{
return val.as_double();
return val.is_null() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
}
int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val)

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -4,7 +4,7 @@
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.2-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/