mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
[C++][Pistache] Add compatibility for nlohmann-json 3.5.0 (#3306)
* [C++][Pistache] Replace contains with find on json object This makes generator compatible with nlohmann-json 3.5.0 * [C++][Pistache] Update Petstore sample
This commit is contained in:
parent
4843dfc244
commit
c1df082d65
@ -37,7 +37,7 @@ void to_json(nlohmann::json& j, const {{classname}}& o)
|
||||
void from_json(const nlohmann::json& j, {{classname}}& o)
|
||||
{
|
||||
{{#vars}}
|
||||
{{#required}}j.at("{{baseName}}").get_to(o.m_{{name}});{{/required}}{{^required}}if(j.contains("{{baseName}}"))
|
||||
{{#required}}j.at("{{baseName}}").get_to(o.m_{{name}});{{/required}}{{^required}}if(j.find("{{baseName}}") != j.end())
|
||||
{
|
||||
j.at("{{baseName}}").get_to(o.m_{{name}});
|
||||
o.m_{{name}}IsSet = true;
|
||||
|
@ -51,17 +51,17 @@ void to_json(nlohmann::json& j, const ApiResponse& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, ApiResponse& o)
|
||||
{
|
||||
if(j.contains("code"))
|
||||
if(j.find("code") != j.end())
|
||||
{
|
||||
j.at("code").get_to(o.m_Code);
|
||||
o.m_CodeIsSet = true;
|
||||
}
|
||||
if(j.contains("type"))
|
||||
if(j.find("type") != j.end())
|
||||
{
|
||||
j.at("type").get_to(o.m_Type);
|
||||
o.m_TypeIsSet = true;
|
||||
}
|
||||
if(j.contains("message"))
|
||||
if(j.find("message") != j.end())
|
||||
{
|
||||
j.at("message").get_to(o.m_Message);
|
||||
o.m_MessageIsSet = true;
|
||||
|
@ -47,12 +47,12 @@ void to_json(nlohmann::json& j, const Category& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, Category& o)
|
||||
{
|
||||
if(j.contains("id"))
|
||||
if(j.find("id") != j.end())
|
||||
{
|
||||
j.at("id").get_to(o.m_Id);
|
||||
o.m_IdIsSet = true;
|
||||
}
|
||||
if(j.contains("name"))
|
||||
if(j.find("name") != j.end())
|
||||
{
|
||||
j.at("name").get_to(o.m_Name);
|
||||
o.m_NameIsSet = true;
|
||||
|
@ -47,12 +47,12 @@ void to_json(nlohmann::json& j, const Inline_object& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, Inline_object& o)
|
||||
{
|
||||
if(j.contains("name"))
|
||||
if(j.find("name") != j.end())
|
||||
{
|
||||
j.at("name").get_to(o.m_Name);
|
||||
o.m_NameIsSet = true;
|
||||
}
|
||||
if(j.contains("status"))
|
||||
if(j.find("status") != j.end())
|
||||
{
|
||||
j.at("status").get_to(o.m_Status);
|
||||
o.m_StatusIsSet = true;
|
||||
|
@ -46,12 +46,12 @@ void to_json(nlohmann::json& j, const Inline_object_1& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, Inline_object_1& o)
|
||||
{
|
||||
if(j.contains("additionalMetadata"))
|
||||
if(j.find("additionalMetadata") != j.end())
|
||||
{
|
||||
j.at("additionalMetadata").get_to(o.m_AdditionalMetadata);
|
||||
o.m_AdditionalMetadataIsSet = true;
|
||||
}
|
||||
if(j.contains("file"))
|
||||
if(j.find("file") != j.end())
|
||||
{
|
||||
j.at("file").get_to(o.m_file);
|
||||
o.m_fileIsSet = true;
|
||||
|
@ -63,32 +63,32 @@ void to_json(nlohmann::json& j, const Order& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, Order& o)
|
||||
{
|
||||
if(j.contains("id"))
|
||||
if(j.find("id") != j.end())
|
||||
{
|
||||
j.at("id").get_to(o.m_Id);
|
||||
o.m_IdIsSet = true;
|
||||
}
|
||||
if(j.contains("petId"))
|
||||
if(j.find("petId") != j.end())
|
||||
{
|
||||
j.at("petId").get_to(o.m_PetId);
|
||||
o.m_PetIdIsSet = true;
|
||||
}
|
||||
if(j.contains("quantity"))
|
||||
if(j.find("quantity") != j.end())
|
||||
{
|
||||
j.at("quantity").get_to(o.m_Quantity);
|
||||
o.m_QuantityIsSet = true;
|
||||
}
|
||||
if(j.contains("shipDate"))
|
||||
if(j.find("shipDate") != j.end())
|
||||
{
|
||||
j.at("shipDate").get_to(o.m_ShipDate);
|
||||
o.m_ShipDateIsSet = true;
|
||||
}
|
||||
if(j.contains("status"))
|
||||
if(j.find("status") != j.end())
|
||||
{
|
||||
j.at("status").get_to(o.m_Status);
|
||||
o.m_StatusIsSet = true;
|
||||
}
|
||||
if(j.contains("complete"))
|
||||
if(j.find("complete") != j.end())
|
||||
{
|
||||
j.at("complete").get_to(o.m_Complete);
|
||||
o.m_CompleteIsSet = true;
|
||||
|
@ -56,24 +56,24 @@ void to_json(nlohmann::json& j, const Pet& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, Pet& o)
|
||||
{
|
||||
if(j.contains("id"))
|
||||
if(j.find("id") != j.end())
|
||||
{
|
||||
j.at("id").get_to(o.m_Id);
|
||||
o.m_IdIsSet = true;
|
||||
}
|
||||
if(j.contains("category"))
|
||||
if(j.find("category") != j.end())
|
||||
{
|
||||
j.at("category").get_to(o.m_Category);
|
||||
o.m_CategoryIsSet = true;
|
||||
}
|
||||
j.at("name").get_to(o.m_Name);
|
||||
j.at("photoUrls").get_to(o.m_PhotoUrls);
|
||||
if(j.contains("tags"))
|
||||
if(j.find("tags") != j.end())
|
||||
{
|
||||
j.at("tags").get_to(o.m_Tags);
|
||||
o.m_TagsIsSet = true;
|
||||
}
|
||||
if(j.contains("status"))
|
||||
if(j.find("status") != j.end())
|
||||
{
|
||||
j.at("status").get_to(o.m_Status);
|
||||
o.m_StatusIsSet = true;
|
||||
|
@ -47,12 +47,12 @@ void to_json(nlohmann::json& j, const Tag& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, Tag& o)
|
||||
{
|
||||
if(j.contains("id"))
|
||||
if(j.find("id") != j.end())
|
||||
{
|
||||
j.at("id").get_to(o.m_Id);
|
||||
o.m_IdIsSet = true;
|
||||
}
|
||||
if(j.contains("name"))
|
||||
if(j.find("name") != j.end())
|
||||
{
|
||||
j.at("name").get_to(o.m_Name);
|
||||
o.m_NameIsSet = true;
|
||||
|
@ -71,42 +71,42 @@ void to_json(nlohmann::json& j, const User& o)
|
||||
|
||||
void from_json(const nlohmann::json& j, User& o)
|
||||
{
|
||||
if(j.contains("id"))
|
||||
if(j.find("id") != j.end())
|
||||
{
|
||||
j.at("id").get_to(o.m_Id);
|
||||
o.m_IdIsSet = true;
|
||||
}
|
||||
if(j.contains("username"))
|
||||
if(j.find("username") != j.end())
|
||||
{
|
||||
j.at("username").get_to(o.m_Username);
|
||||
o.m_UsernameIsSet = true;
|
||||
}
|
||||
if(j.contains("firstName"))
|
||||
if(j.find("firstName") != j.end())
|
||||
{
|
||||
j.at("firstName").get_to(o.m_FirstName);
|
||||
o.m_FirstNameIsSet = true;
|
||||
}
|
||||
if(j.contains("lastName"))
|
||||
if(j.find("lastName") != j.end())
|
||||
{
|
||||
j.at("lastName").get_to(o.m_LastName);
|
||||
o.m_LastNameIsSet = true;
|
||||
}
|
||||
if(j.contains("email"))
|
||||
if(j.find("email") != j.end())
|
||||
{
|
||||
j.at("email").get_to(o.m_Email);
|
||||
o.m_EmailIsSet = true;
|
||||
}
|
||||
if(j.contains("password"))
|
||||
if(j.find("password") != j.end())
|
||||
{
|
||||
j.at("password").get_to(o.m_Password);
|
||||
o.m_PasswordIsSet = true;
|
||||
}
|
||||
if(j.contains("phone"))
|
||||
if(j.find("phone") != j.end())
|
||||
{
|
||||
j.at("phone").get_to(o.m_Phone);
|
||||
o.m_PhoneIsSet = true;
|
||||
}
|
||||
if(j.contains("userStatus"))
|
||||
if(j.find("userStatus") != j.end())
|
||||
{
|
||||
j.at("userStatus").get_to(o.m_UserStatus);
|
||||
o.m_UserStatusIsSet = true;
|
||||
|
Loading…
Reference in New Issue
Block a user