Skip to content

Commit

Permalink
fix cpp-restbed-server json field serialization OpenAPITools#4320
Browse files Browse the repository at this point in the history
  • Loading branch information
lwlee2608 committed Oct 30, 2019
1 parent 2188e0f commit 2337f4e
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -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}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1-SNAPSHOT
4.2.0-SNAPSHOT
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/api/PetApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/api/PetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/api/StoreApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/api/StoreApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/api/UserApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/api/UserApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
15 changes: 11 additions & 4 deletions samples/server/petstore/cpp-restbed/git_push.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -37,15 +43,16 @@ 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

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'

14 changes: 7 additions & 7 deletions samples/server/petstore/cpp-restbed/model/ApiResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/model/ApiResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
10 changes: 5 additions & 5 deletions samples/server/petstore/cpp-restbed/model/Category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/model/Category.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
26 changes: 13 additions & 13 deletions samples/server/petstore/cpp-restbed/model/Order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/model/Order.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
14 changes: 7 additions & 7 deletions samples/server/petstore/cpp-restbed/model/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/model/Pet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
10 changes: 5 additions & 5 deletions samples/server/petstore/cpp-restbed/model/Tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-restbed/model/Tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Loading

0 comments on commit 2337f4e

Please sign in to comment.