fix cpp-restbed-server json field serialization #4320 (#4323)

This commit is contained in:
lwlee2608 2019-11-01 10:56:12 +08:00 committed by William Cheng
parent cf29908ff2
commit a9ea8636e5
21 changed files with 84 additions and 77 deletions

View File

@ -35,14 +35,14 @@ std::string {{classname}}::toJsonString()
{{#vars}}
{{^isContainer}}
{{#isPrimitiveType}}
pt.put("{{name}}", m_{{name}});
pt.put("{{baseName}}", m_{{name}});
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isString}}
pt.put("{{name}}", m_{{name}});
pt.put("{{baseName}}", m_{{name}});
{{/isString}}
{{#isDateTime}}
pt.put("{{name}}", m_{{name}});
pt.put("{{baseName}}", m_{{name}});
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isContainer}}
@ -59,14 +59,14 @@ void {{classname}}::fromJsonString(std::string const& jsonString)
{{#vars}}
{{^isContainer}}
{{#isPrimitiveType}}
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
m_{{name}} = pt.get("{{baseName}}", {{{defaultValue}}});
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isString}}
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
m_{{name}} = pt.get("{{baseName}}", {{{defaultValue}}});
{{/isString}}
{{#isDateTime}}
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
m_{{name}} = pt.get("{{baseName}}", {{{defaultValue}}});
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isContainer}}

View File

@ -1 +1 @@
4.0.1-SNAPSHOT
4.2.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-cpprest "minor update"
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@ -47,5 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -5,7 +5,7 @@
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.2.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@ -44,9 +44,9 @@ std::string ApiResponse::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("Code", m_Code);
pt.put("Type", m_Type);
pt.put("Message", m_Message);
pt.put("code", m_Code);
pt.put("type", m_Type);
pt.put("message", m_Message);
write_json(ss, pt, false);
return ss.str();
}
@ -56,9 +56,9 @@ void ApiResponse::fromJsonString(std::string const& jsonString)
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
m_Code = pt.get("Code", 0);
m_Type = pt.get("Type", "");
m_Message = pt.get("Message", "");
m_Code = pt.get("code", 0);
m_Type = pt.get("type", "");
m_Message = pt.get("message", "");
}
int32_t ApiResponse::getCode() const

View File

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

View File

@ -5,7 +5,7 @@
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.2.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@ -43,8 +43,8 @@ std::string Category::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("Id", m_Id);
pt.put("Name", m_Name);
pt.put("id", m_Id);
pt.put("name", m_Name);
write_json(ss, pt, false);
return ss.str();
}
@ -54,8 +54,8 @@ void Category::fromJsonString(std::string const& jsonString)
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
m_Id = pt.get("Id", 0L);
m_Name = pt.get("Name", "");
m_Id = pt.get("id", 0L);
m_Name = pt.get("name", "");
}
int64_t Category::getId() const

View File

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

View File

@ -5,7 +5,7 @@
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.2.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@ -47,12 +47,12 @@ std::string Order::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("Id", m_Id);
pt.put("PetId", m_PetId);
pt.put("Quantity", m_Quantity);
pt.put("ShipDate", m_ShipDate);
pt.put("Status", m_Status);
pt.put("Complete", m_Complete);
pt.put("id", m_Id);
pt.put("petId", m_PetId);
pt.put("quantity", m_Quantity);
pt.put("shipDate", m_ShipDate);
pt.put("status", m_Status);
pt.put("complete", m_Complete);
write_json(ss, pt, false);
return ss.str();
}
@ -62,12 +62,12 @@ void Order::fromJsonString(std::string const& jsonString)
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
m_Id = pt.get("Id", 0L);
m_PetId = pt.get("PetId", 0L);
m_Quantity = pt.get("Quantity", 0);
m_ShipDate = pt.get("ShipDate", "");
m_Status = pt.get("Status", "");
m_Complete = pt.get("Complete", false);
m_Id = pt.get("id", 0L);
m_PetId = pt.get("petId", 0L);
m_Quantity = pt.get("quantity", 0);
m_ShipDate = pt.get("shipDate", "");
m_Status = pt.get("status", "");
m_Complete = pt.get("complete", false);
}
int64_t Order::getId() const

View File

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

View File

@ -5,7 +5,7 @@
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.2.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@ -44,9 +44,9 @@ std::string Pet::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("Id", m_Id);
pt.put("Name", m_Name);
pt.put("Status", m_Status);
pt.put("id", m_Id);
pt.put("name", m_Name);
pt.put("status", m_Status);
write_json(ss, pt, false);
return ss.str();
}
@ -56,9 +56,9 @@ void Pet::fromJsonString(std::string const& jsonString)
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
m_Id = pt.get("Id", 0L);
m_Name = pt.get("Name", "");
m_Status = pt.get("Status", "");
m_Id = pt.get("id", 0L);
m_Name = pt.get("name", "");
m_Status = pt.get("status", "");
}
int64_t Pet::getId() const

View File

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

View File

@ -5,7 +5,7 @@
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.2.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@ -43,8 +43,8 @@ std::string Tag::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("Id", m_Id);
pt.put("Name", m_Name);
pt.put("id", m_Id);
pt.put("name", m_Name);
write_json(ss, pt, false);
return ss.str();
}
@ -54,8 +54,8 @@ void Tag::fromJsonString(std::string const& jsonString)
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
m_Id = pt.get("Id", 0L);
m_Name = pt.get("Name", "");
m_Id = pt.get("id", 0L);
m_Name = pt.get("name", "");
}
int64_t Tag::getId() const

View File

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

View File

@ -5,7 +5,7 @@
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator 4.2.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@ -49,14 +49,14 @@ std::string User::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("Id", m_Id);
pt.put("Username", m_Username);
pt.put("FirstName", m_FirstName);
pt.put("LastName", m_LastName);
pt.put("Email", m_Email);
pt.put("Password", m_Password);
pt.put("Phone", m_Phone);
pt.put("UserStatus", m_UserStatus);
pt.put("id", m_Id);
pt.put("username", m_Username);
pt.put("firstName", m_FirstName);
pt.put("lastName", m_LastName);
pt.put("email", m_Email);
pt.put("password", m_Password);
pt.put("phone", m_Phone);
pt.put("userStatus", m_UserStatus);
write_json(ss, pt, false);
return ss.str();
}
@ -66,14 +66,14 @@ void User::fromJsonString(std::string const& jsonString)
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
m_Id = pt.get("Id", 0L);
m_Username = pt.get("Username", "");
m_FirstName = pt.get("FirstName", "");
m_LastName = pt.get("LastName", "");
m_Email = pt.get("Email", "");
m_Password = pt.get("Password", "");
m_Phone = pt.get("Phone", "");
m_UserStatus = pt.get("UserStatus", 0);
m_Id = pt.get("id", 0L);
m_Username = pt.get("username", "");
m_FirstName = pt.get("firstName", "");
m_LastName = pt.get("lastName", "");
m_Email = pt.get("email", "");
m_Password = pt.get("password", "");
m_Phone = pt.get("phone", "");
m_UserStatus = pt.get("userStatus", 0);
}
int64_t User::getId() const

View File

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