From be1209111057c10853937386dbcaa64b32d20c76 Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sat, 9 Jun 2018 17:16:51 +0200 Subject: [PATCH 01/10] Added missing includes for optional --- .../.openapi-generator/VERSION | 2 +- .../codegen/languages/CppPistacheServerCodegen.java | 10 +++++----- .../resources/cpp-pistache-server/api-header.mustache | 2 ++ .../cpp-pistache-server/api-impl-header.mustache | 2 ++ samples/server/petstore/cpp-pistache/api/PetApi.h | 8 +++++--- samples/server/petstore/cpp-pistache/api/StoreApi.h | 2 ++ samples/server/petstore/cpp-pistache/api/UserApi.h | 4 +++- .../server/petstore/cpp-pistache/impl/PetApiImpl.cpp | 6 +++--- samples/server/petstore/cpp-pistache/impl/PetApiImpl.h | 8 +++++--- .../server/petstore/cpp-pistache/impl/StoreApiImpl.h | 2 ++ .../server/petstore/cpp-pistache/impl/UserApiImpl.cpp | 2 +- .../server/petstore/cpp-pistache/impl/UserApiImpl.h | 4 +++- 12 files changed, 34 insertions(+), 18 deletions(-) diff --git a/modules/openapi-generator-online/.openapi-generator/VERSION b/modules/openapi-generator-online/.openapi-generator/VERSION index 096bf47efe31..ad121e8340e0 100644 --- a/modules/openapi-generator-online/.openapi-generator/VERSION +++ b/modules/openapi-generator-online/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.0.1-SNAPSHOT \ No newline at end of file diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index 1bbfafbce377..732f37560045 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -219,14 +219,14 @@ public Map postProcessOperations(Map objs) { //TODO: This changes the info about the real type but it is needed to parse the header params if (param.isHeaderParam) { - param.dataType = "Optional"; - param.baseType = "Optional"; + param.dataType = "Pistache::Optional"; + param.baseType = "Pistache::Optional"; } else if (param.isQueryParam) { if (param.isPrimitiveType) { - param.dataType = "Optional<" + param.dataType + ">"; + param.dataType = "Pistache::Optional<" + param.dataType + ">"; } else { - param.dataType = "Optional<" + param.baseType + ">"; - param.baseType = "Optional<" + param.baseType + ">"; + param.dataType = "Pistache::Optional<" + param.baseType + ">"; + param.baseType = "Pistache::Optional<" + param.baseType + ">"; } } } diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache index 735fe5c1b7b6..835f0a89b2c5 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache @@ -14,6 +14,8 @@ #include #include +#include + {{#imports}}{{{import}}} {{/imports}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache index b253948959b0..3aa6d5bc4212 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache @@ -17,6 +17,8 @@ #include <{{classname}}.h> +#include + {{#imports}}{{{import}}} {{/imports}} diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.h b/samples/server/petstore/cpp-pistache/api/PetApi.h index c5950fa4fae7..68ae4f9c7cf8 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.h +++ b/samples/server/petstore/cpp-pistache/api/PetApi.h @@ -24,6 +24,8 @@ #include #include +#include + #include "ApiResponse.h" #include "Pet.h" #include @@ -79,7 +81,7 @@ class PetApi { /// /// Pet id to delete /// (optional) - virtual void delete_pet(const int64_t &petId, const Optional &apiKey, Pistache::Http::ResponseWriter &response) = 0; + virtual void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response) = 0; /// /// Finds Pets by status @@ -88,7 +90,7 @@ class PetApi { /// Multiple status values can be provided with comma separated strings /// /// Status values that need to be considered for filter - virtual void find_pets_by_status(const Optional &status, Pistache::Http::ResponseWriter &response) = 0; + virtual void find_pets_by_status(const Pistache::Optional &status, Pistache::Http::ResponseWriter &response) = 0; /// /// Finds Pets by tags @@ -97,7 +99,7 @@ class PetApi { /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// /// Tags to filter by - virtual void find_pets_by_tags(const Optional &tags, Pistache::Http::ResponseWriter &response) = 0; + virtual void find_pets_by_tags(const Pistache::Optional &tags, Pistache::Http::ResponseWriter &response) = 0; /// /// Find pet by ID diff --git a/samples/server/petstore/cpp-pistache/api/StoreApi.h b/samples/server/petstore/cpp-pistache/api/StoreApi.h index a243444e8fac..e8d26ee75f21 100644 --- a/samples/server/petstore/cpp-pistache/api/StoreApi.h +++ b/samples/server/petstore/cpp-pistache/api/StoreApi.h @@ -24,6 +24,8 @@ #include #include +#include + #include "Order.h" #include #include diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.h b/samples/server/petstore/cpp-pistache/api/UserApi.h index 623bf8b65088..53e459871e44 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.h +++ b/samples/server/petstore/cpp-pistache/api/UserApi.h @@ -24,6 +24,8 @@ #include #include +#include + #include "User.h" #include #include @@ -115,7 +117,7 @@ class UserApi { /// /// The user name for login /// The password for login in clear text - virtual void login_user(const Optional &username, const Optional &password, Pistache::Http::ResponseWriter &response) = 0; + virtual void login_user(const Pistache::Optional &username, const Pistache::Optional &password, Pistache::Http::ResponseWriter &response) = 0; /// /// Logs out current logged in user session diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp index 6e1a5d742f6c..09d880a6631b 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp @@ -26,13 +26,13 @@ PetApiImpl::PetApiImpl(Pistache::Address addr) void PetApiImpl::add_pet(const std::shared_ptr &pet, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } -void PetApiImpl::delete_pet(const int64_t &petId, const Optional &apiKey, Pistache::Http::ResponseWriter &response) { +void PetApiImpl::delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } -void PetApiImpl::find_pets_by_status(const Optional &status, Pistache::Http::ResponseWriter &response) { +void PetApiImpl::find_pets_by_status(const Pistache::Optional &status, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } -void PetApiImpl::find_pets_by_tags(const Optional &tags, Pistache::Http::ResponseWriter &response) { +void PetApiImpl::find_pets_by_tags(const Pistache::Optional &tags, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } void PetApiImpl::get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response) { diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h index 020f8993a345..c0a7624cc044 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h @@ -27,6 +27,8 @@ #include +#include + #include "ApiResponse.h" #include "Pet.h" #include @@ -44,9 +46,9 @@ class PetApiImpl : public org::openapitools::server::api::PetApi { ~PetApiImpl() { }; void add_pet(const std::shared_ptr &pet, Pistache::Http::ResponseWriter &response); - void delete_pet(const int64_t &petId, const Optional &apiKey, Pistache::Http::ResponseWriter &response); - void find_pets_by_status(const Optional &status, Pistache::Http::ResponseWriter &response); - void find_pets_by_tags(const Optional &tags, Pistache::Http::ResponseWriter &response); + void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response); + void find_pets_by_status(const Pistache::Optional &status, Pistache::Http::ResponseWriter &response); + void find_pets_by_tags(const Pistache::Optional &tags, Pistache::Http::ResponseWriter &response); void get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response); void update_pet(const std::shared_ptr &pet, Pistache::Http::ResponseWriter &response); void update_pet_with_form(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response); diff --git a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h index 3a7f42923ef9..97574ec3ea0c 100644 --- a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h @@ -27,6 +27,8 @@ #include +#include + #include "Order.h" #include #include diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp index c764c5821dae..3cb2619df891 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp @@ -38,7 +38,7 @@ void UserApiImpl::delete_user(const std::string &username, Pistache::Http::Respo void UserApiImpl::get_user_by_name(const std::string &username, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } -void UserApiImpl::login_user(const Optional &username, const Optional &password, Pistache::Http::ResponseWriter &response) { +void UserApiImpl::login_user(const Pistache::Optional &username, const Pistache::Optional &password, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } void UserApiImpl::logout_user(Pistache::Http::ResponseWriter &response) { diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h index 1569be6b1d49..cdc5e3881c36 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h @@ -27,6 +27,8 @@ #include +#include + #include "User.h" #include #include @@ -48,7 +50,7 @@ class UserApiImpl : public org::openapitools::server::api::UserApi { void create_users_with_list_input(const std::vector> &user, Pistache::Http::ResponseWriter &response); void delete_user(const std::string &username, Pistache::Http::ResponseWriter &response); void get_user_by_name(const std::string &username, Pistache::Http::ResponseWriter &response); - void login_user(const Optional &username, const Optional &password, Pistache::Http::ResponseWriter &response); + void login_user(const Pistache::Optional &username, const Pistache::Optional &password, Pistache::Http::ResponseWriter &response); void logout_user(Pistache::Http::ResponseWriter &response); void update_user(const std::string &username, const std::shared_ptr &user, Pistache::Http::ResponseWriter &response); From dde984475869a03300f5312f5b7f20ddc25b57a6 Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sat, 9 Jun 2018 17:50:03 +0200 Subject: [PATCH 02/10] Removed shared pointer from pistache generator --- .../codegen/languages/CppPistacheServerCodegen.java | 12 ++++++------ .../cpp-pistache-server/api-header.mustache | 2 +- .../cpp-pistache-server/api-impl-header.mustache | 2 +- .../cpp-pistache-server/api-impl-source.mustache | 2 +- samples/server/petstore/cpp-pistache/api/UserApi.h | 4 ++-- .../petstore/cpp-pistache/impl/UserApiImpl.cpp | 4 ++-- .../server/petstore/cpp-pistache/impl/UserApiImpl.h | 4 ++-- samples/server/petstore/cpp-pistache/model/Pet.cpp | 12 ++++++------ samples/server/petstore/cpp-pistache/model/Pet.h | 10 +++++----- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index 732f37560045..52928fbfd6fc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -299,7 +299,7 @@ public String getTypeDeclaration(Schema p) { return toModelName(openAPIType); } - return "std::shared_ptr<" + openAPIType + ">"; + return openAPIType; } @Override @@ -327,16 +327,16 @@ public String toDefaultValue(Schema p) { ArraySchema ap = (ArraySchema) p; String inner = getSchemaType(ap.getItems()); if (!languageSpecificPrimitives.contains(inner)) { - inner = "std::shared_ptr<" + inner + ">"; + inner = inner; } return "std::vector<" + inner + ">()"; } else if (!StringUtils.isEmpty(p.get$ref())) { // model - return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()"; + return toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()"; } else if (ModelUtils.isStringSchema(p)) { return "\"\""; } - return "nullptr"; + return ""; } @Override @@ -347,8 +347,8 @@ public void postProcessParameter(CodegenParameter parameter) { boolean isListContainer = parameter.isListContainer == Boolean.TRUE; boolean isString = parameter.isString == Boolean.TRUE; - if (!isPrimitiveType && !isListContainer && !isString && !parameter.dataType.startsWith("std::shared_ptr")) { - parameter.dataType = "std::shared_ptr<" + parameter.dataType + ">"; + if (!isPrimitiveType && !isListContainer && !isString) { + parameter.dataType = parameter.dataType; } } diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache index 835f0a89b2c5..7830ff6c76dc 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache @@ -58,7 +58,7 @@ private: {{#allParams}} /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} {{/allParams}} - virtual void {{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; + virtual void {{operationIdSnakeCase}}({{#allParams}}const {{^isComplexType}}{{{dataType}}}{{/isComplexType}}{{#isComplexType}}{{{baseType}}}{{/isComplexType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; {{/vendorExtensions.x-codegen-pistache-isParsingSupported}} {{^vendorExtensions.x-codegen-pistache-isParsingSupported}} virtual void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0; diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache index 3aa6d5bc4212..640d79b0188a 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache @@ -35,7 +35,7 @@ public: {{#operation}} {{#vendorExtensions.x-codegen-pistache-isParsingSupported}} - void {{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response); + void {{operationIdSnakeCase}}({{#allParams}}const {{^isComplexType}}{{{dataType}}}{{/isComplexType}}{{#isComplexType}}{{{baseType}}}{{/isComplexType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response); {{/vendorExtensions.x-codegen-pistache-isParsingSupported}} {{^vendorExtensions.x-codegen-pistache-isParsingSupported}} void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response); diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache index a3babcd5cadb..d403b6b5869f 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache @@ -15,7 +15,7 @@ using namespace {{modelNamespace}}; {{#operation}} {{#vendorExtensions.x-codegen-pistache-isParsingSupported}} -void {{classname}}Impl::{{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) { +void {{classname}}Impl::{{operationIdSnakeCase}}({{#allParams}}const {{^isComplexType}}{{{dataType}}}{{/isComplexType}}{{#isComplexType}}{{{baseType}}}{{/isComplexType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } {{/vendorExtensions.x-codegen-pistache-isParsingSupported}} diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.h b/samples/server/petstore/cpp-pistache/api/UserApi.h index 53e459871e44..375ba3b401eb 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.h +++ b/samples/server/petstore/cpp-pistache/api/UserApi.h @@ -80,7 +80,7 @@ class UserApi { /// /// /// List of user object - virtual void create_users_with_array_input(const std::vector> &user, Pistache::Http::ResponseWriter &response) = 0; + virtual void create_users_with_array_input(const std::vector &user, Pistache::Http::ResponseWriter &response) = 0; /// /// Creates list of users with given input array @@ -89,7 +89,7 @@ class UserApi { /// /// /// List of user object - virtual void create_users_with_list_input(const std::vector> &user, Pistache::Http::ResponseWriter &response) = 0; + virtual void create_users_with_list_input(const std::vector &user, Pistache::Http::ResponseWriter &response) = 0; /// /// Delete user diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp index 3cb2619df891..6d5ce9c5aaf2 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp @@ -26,10 +26,10 @@ UserApiImpl::UserApiImpl(Pistache::Address addr) void UserApiImpl::create_user(const std::shared_ptr &user, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } -void UserApiImpl::create_users_with_array_input(const std::vector> &user, Pistache::Http::ResponseWriter &response) { +void UserApiImpl::create_users_with_array_input(const std::vector &user, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } -void UserApiImpl::create_users_with_list_input(const std::vector> &user, Pistache::Http::ResponseWriter &response) { +void UserApiImpl::create_users_with_list_input(const std::vector &user, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } void UserApiImpl::delete_user(const std::string &username, Pistache::Http::ResponseWriter &response) { diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h index cdc5e3881c36..e719edba1416 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h @@ -46,8 +46,8 @@ class UserApiImpl : public org::openapitools::server::api::UserApi { ~UserApiImpl() { }; void create_user(const std::shared_ptr &user, Pistache::Http::ResponseWriter &response); - void create_users_with_array_input(const std::vector> &user, Pistache::Http::ResponseWriter &response); - void create_users_with_list_input(const std::vector> &user, Pistache::Http::ResponseWriter &response); + void create_users_with_array_input(const std::vector &user, Pistache::Http::ResponseWriter &response); + void create_users_with_list_input(const std::vector &user, Pistache::Http::ResponseWriter &response); void delete_user(const std::string &username, Pistache::Http::ResponseWriter &response); void get_user_by_name(const std::string &username, Pistache::Http::ResponseWriter &response); void login_user(const Pistache::Optional &username, const Pistache::Optional &password, Pistache::Http::ResponseWriter &response); diff --git a/samples/server/petstore/cpp-pistache/model/Pet.cpp b/samples/server/petstore/cpp-pistache/model/Pet.cpp index 58447515d421..3e24bf430742 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.cpp +++ b/samples/server/petstore/cpp-pistache/model/Pet.cpp @@ -91,7 +91,7 @@ void Pet::fromJson(nlohmann::json& val) { if(!val["category"].is_null()) { - std::shared_ptr newItem(new Category()); + Category newItem(Category()); newItem->fromJson(val["category"]); setCategory( newItem ); } @@ -117,11 +117,11 @@ void Pet::fromJson(nlohmann::json& val) if(item.is_null()) { - m_Tags.push_back( std::shared_ptr(nullptr) ); + m_Tags.push_back( Tag(nullptr) ); } else { - std::shared_ptr newItem(new Tag()); + Tag newItem(Tag()); newItem->fromJson(item); m_Tags.push_back( newItem ); } @@ -155,11 +155,11 @@ void Pet::unsetId() { m_IdIsSet = false; } -std::shared_ptr Pet::getCategory() const +Category Pet::getCategory() const { return m_Category; } -void Pet::setCategory(std::shared_ptr value) +void Pet::setCategory(Category value) { m_Category = value; m_CategoryIsSet = true; @@ -185,7 +185,7 @@ std::vector& Pet::getPhotoUrls() { return m_PhotoUrls; } -std::vector>& Pet::getTags() +std::vector& Pet::getTags() { return m_Tags; } diff --git a/samples/server/petstore/cpp-pistache/model/Pet.h b/samples/server/petstore/cpp-pistache/model/Pet.h index d0d84c4aeacd..455baf5a1e78 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.h +++ b/samples/server/petstore/cpp-pistache/model/Pet.h @@ -62,8 +62,8 @@ class Pet /// /// /// - std::shared_ptr getCategory() const; - void setCategory(std::shared_ptr value); + Category getCategory() const; + void setCategory(Category value); bool categoryIsSet() const; void unsetCategory(); /// @@ -78,7 +78,7 @@ class Pet /// /// /// - std::vector>& getTags(); + std::vector& getTags(); bool tagsIsSet() const; void unsetTags(); /// @@ -92,13 +92,13 @@ class Pet protected: int64_t m_Id; bool m_IdIsSet; - std::shared_ptr m_Category; + Category m_Category; bool m_CategoryIsSet; std::string m_Name; std::vector m_PhotoUrls; - std::vector> m_Tags; + std::vector m_Tags; bool m_TagsIsSet; std::string m_Status; bool m_StatusIsSet; From 770737b44f9e607598b4d0c022d61d011400efdf Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sat, 9 Jun 2018 17:58:55 +0200 Subject: [PATCH 03/10] Changed Net namespace to Pistache Namespace --- .../codegen/languages/CppPistacheServerCodegen.java | 4 ++-- samples/server/petstore/cpp-pistache/api/PetApi.h | 2 +- samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp | 2 +- samples/server/petstore/cpp-pistache/impl/PetApiImpl.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index 52928fbfd6fc..b82dc683a89a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -219,8 +219,8 @@ public Map postProcessOperations(Map objs) { //TODO: This changes the info about the real type but it is needed to parse the header params if (param.isHeaderParam) { - param.dataType = "Pistache::Optional"; - param.baseType = "Pistache::Optional"; + param.dataType = "Pistache::Optional"; + param.baseType = "Pistache::Optional"; } else if (param.isQueryParam) { if (param.isPrimitiveType) { param.dataType = "Pistache::Optional<" + param.dataType + ">"; diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.h b/samples/server/petstore/cpp-pistache/api/PetApi.h index 68ae4f9c7cf8..f717727713ef 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.h +++ b/samples/server/petstore/cpp-pistache/api/PetApi.h @@ -81,7 +81,7 @@ class PetApi { /// /// Pet id to delete /// (optional) - virtual void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response) = 0; + virtual void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response) = 0; /// /// Finds Pets by status diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp index 09d880a6631b..e987ecf23717 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp @@ -26,7 +26,7 @@ PetApiImpl::PetApiImpl(Pistache::Address addr) void PetApiImpl::add_pet(const std::shared_ptr &pet, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } -void PetApiImpl::delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response) { +void PetApiImpl::delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } void PetApiImpl::find_pets_by_status(const Pistache::Optional &status, Pistache::Http::ResponseWriter &response) { diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h index c0a7624cc044..b83c14efb27d 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h @@ -46,7 +46,7 @@ class PetApiImpl : public org::openapitools::server::api::PetApi { ~PetApiImpl() { }; void add_pet(const std::shared_ptr &pet, Pistache::Http::ResponseWriter &response); - void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response); + void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response); void find_pets_by_status(const Pistache::Optional &status, Pistache::Http::ResponseWriter &response); void find_pets_by_tags(const Pistache::Optional &tags, Pistache::Http::ResponseWriter &response); void get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response); From d128153e83638f3ce7a6df514f0decfb6ed3d6e4 Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sat, 9 Jun 2018 18:09:22 +0200 Subject: [PATCH 04/10] Clean up code and removed unnecessary lines in mustache files --- .../codegen/languages/CppPistacheServerCodegen.java | 13 ------------- .../cpp-pistache-server/api-header.mustache | 2 +- .../cpp-pistache-server/api-impl-header.mustache | 2 +- .../cpp-pistache-server/api-impl-source.mustache | 2 +- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index b82dc683a89a..4bd16a60bad2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -339,19 +339,6 @@ public String toDefaultValue(Schema p) { return ""; } - @Override - public void postProcessParameter(CodegenParameter parameter) { - super.postProcessParameter(parameter); - - boolean isPrimitiveType = parameter.isPrimitiveType == Boolean.TRUE; - boolean isListContainer = parameter.isListContainer == Boolean.TRUE; - boolean isString = parameter.isString == Boolean.TRUE; - - if (!isPrimitiveType && !isListContainer && !isString) { - parameter.dataType = parameter.dataType; - } - } - /** * Location to write model files. You can use the modelPackage() as defined * when the class is instantiated diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache index 7830ff6c76dc..835f0a89b2c5 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache @@ -58,7 +58,7 @@ private: {{#allParams}} /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} {{/allParams}} - virtual void {{operationIdSnakeCase}}({{#allParams}}const {{^isComplexType}}{{{dataType}}}{{/isComplexType}}{{#isComplexType}}{{{baseType}}}{{/isComplexType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; + virtual void {{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; {{/vendorExtensions.x-codegen-pistache-isParsingSupported}} {{^vendorExtensions.x-codegen-pistache-isParsingSupported}} virtual void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0; diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache index 640d79b0188a..3aa6d5bc4212 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache @@ -35,7 +35,7 @@ public: {{#operation}} {{#vendorExtensions.x-codegen-pistache-isParsingSupported}} - void {{operationIdSnakeCase}}({{#allParams}}const {{^isComplexType}}{{{dataType}}}{{/isComplexType}}{{#isComplexType}}{{{baseType}}}{{/isComplexType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response); + void {{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response); {{/vendorExtensions.x-codegen-pistache-isParsingSupported}} {{^vendorExtensions.x-codegen-pistache-isParsingSupported}} void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response); diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache index d403b6b5869f..a3babcd5cadb 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache @@ -15,7 +15,7 @@ using namespace {{modelNamespace}}; {{#operation}} {{#vendorExtensions.x-codegen-pistache-isParsingSupported}} -void {{classname}}Impl::{{operationIdSnakeCase}}({{#allParams}}const {{^isComplexType}}{{{dataType}}}{{/isComplexType}}{{#isComplexType}}{{{baseType}}}{{/isComplexType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) { +void {{classname}}Impl::{{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); } {{/vendorExtensions.x-codegen-pistache-isParsingSupported}} From 6c924d7d7c54ebd2bc9bee4153897bad44178877 Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sun, 10 Jun 2018 12:42:12 +0200 Subject: [PATCH 05/10] Removed remaining shared pointer syntax --- .../resources/cpp-pistache-server/api-header.mustache | 2 +- .../resources/cpp-pistache-server/api-source.mustache | 10 +++++----- .../cpp-pistache-server/model-source.mustache | 4 ++-- .../cpp-pistache-server/modelbase-header.mustache | 2 +- .../cpp-pistache-server/modelbase-source.mustache | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache index 835f0a89b2c5..1ede8d1a982d 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache @@ -43,7 +43,7 @@ private: {{/operation}} void {{classnameSnakeLowerCase}}_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr httpEndpoint; + Pistache::Http::Endpoint httpEndpoint; Pistache::Rest::Router router; {{#operation}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache index 2545aca76aa8..d815ce10ab7d 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache @@ -10,24 +10,24 @@ namespace {{this}} { using namespace {{modelNamespace}}; {{classname}}::{{classname}}(Pistache::Address addr) - : httpEndpoint(std::make_shared(addr)) + : httpEndpoint(addr) { }; void {{classname}}::init(size_t thr = 2) { auto opts = Pistache::Http::Endpoint::options() .threads(thr) .flags(Pistache::Tcp::Options::InstallSignalHandler); - httpEndpoint->init(opts); + httpEndpoint.init(opts); setupRoutes(); } void {{classname}}::start() { - httpEndpoint->setHandler(router.handler()); - httpEndpoint->serve(); + httpEndpoint.setHandler(router.handler()); + httpEndpoint.serve(); } void {{classname}}::shutdown() { - httpEndpoint->shutdown(); + httpEndpoint.shutdown(); } void {{classname}}::setupRoutes() { diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache index 49f3d1cea59c..60f625c22549 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache @@ -84,7 +84,7 @@ void {{classname}}::fromJson(nlohmann::json& val) else { {{{items.datatype}}} newItem({{{items.defaultValue}}}); - newItem->fromJson(item); + newItem.fromJson(item); m_{{name}}.push_back( newItem ); } {{/items.isDateTime}}{{/items.isString}}{{/isPrimitiveType}} @@ -100,7 +100,7 @@ void {{classname}}::fromJson(nlohmann::json& val) {{/isDateTime}}{{^isDateTime}}if(!val["{{baseName}}"].is_null()) { {{{dataType}}} newItem({{{defaultValue}}}); - newItem->fromJson(val["{{baseName}}"]); + newItem.fromJson(val["{{baseName}}"]); {{setter}}( newItem ); } {{/isDateTime}}{{/isString}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache index 3c18cede5ecb..1f022f34e7fd 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache @@ -34,7 +34,7 @@ public: static int64_t toJson( int64_t value ); static double toJson( double value ); static bool toJson( bool value ); - static nlohmann::json toJson( std::shared_ptr content ); + static nlohmann::json toJson(ModelBase content ); }; diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache index f209bb68761e..87b56ee00361 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache @@ -44,9 +44,9 @@ bool ModelBase::toJson( bool value ) return value; } -nlohmann::json ModelBase::toJson( std::shared_ptr content ) +nlohmann::json ModelBase::toJson(ModelBase content ) { - return content.get() ? content->toJson() : nlohmann::json(); + return content.toJson(); } {{#modelNamespaceDeclarations}} From 1f4fb1cd5f35e4180eb0acfa33a10330106632de Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sun, 10 Jun 2018 15:17:43 +0200 Subject: [PATCH 06/10] Code review fixes + updated samples --- .../languages/CppPistacheServerCodegen.java | 3 --- .../cpp-pistache-server/model-header.mustache | 2 +- .../cpp-pistache-server/model-source.mustache | 2 +- .../server/petstore/cpp-pistache/api/PetApi.cpp | 10 +++++----- .../server/petstore/cpp-pistache/api/PetApi.h | 2 +- .../petstore/cpp-pistache/api/StoreApi.cpp | 10 +++++----- .../server/petstore/cpp-pistache/api/StoreApi.h | 2 +- .../server/petstore/cpp-pistache/api/UserApi.cpp | 10 +++++----- .../server/petstore/cpp-pistache/api/UserApi.h | 2 +- .../petstore/cpp-pistache/model/ApiResponse.cpp | 6 +++--- .../petstore/cpp-pistache/model/ApiResponse.h | 6 +++--- .../petstore/cpp-pistache/model/Category.cpp | 4 ++-- .../petstore/cpp-pistache/model/Category.h | 4 ++-- .../petstore/cpp-pistache/model/ModelBase.cpp | 4 ++-- .../petstore/cpp-pistache/model/ModelBase.h | 2 +- .../server/petstore/cpp-pistache/model/Order.cpp | 12 ++++++------ .../server/petstore/cpp-pistache/model/Order.h | 12 ++++++------ .../server/petstore/cpp-pistache/model/Pet.cpp | 12 ++++++------ samples/server/petstore/cpp-pistache/model/Pet.h | 8 ++++---- .../server/petstore/cpp-pistache/model/Tag.cpp | 4 ++-- samples/server/petstore/cpp-pistache/model/Tag.h | 4 ++-- .../server/petstore/cpp-pistache/model/User.cpp | 16 ++++++++-------- .../server/petstore/cpp-pistache/model/User.h | 16 ++++++++-------- 23 files changed, 75 insertions(+), 78 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index 4bd16a60bad2..6467b33edc9a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -326,9 +326,6 @@ public String toDefaultValue(Schema p) { } else if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; String inner = getSchemaType(ap.getItems()); - if (!languageSpecificPrimitives.contains(inner)) { - inner = inner; - } return "std::vector<" + inner + ">()"; } else if (!StringUtils.isEmpty(p.get$ref())) { // model return toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()"; diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache index 7b095876a387..f0c19afefed2 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache @@ -45,7 +45,7 @@ public: /// {{^isNotContainer}}{{{dataType}}}& {{getter}}(); {{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{getter}}() const; - void {{setter}}({{{dataType}}} value); + void {{setter}}({{{dataType}}}& value); {{/isNotContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const; void unset{{name}}(); {{/required}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache index 60f625c22549..fb1a9d73c2b1 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache @@ -119,7 +119,7 @@ void {{classname}}::fromJson(nlohmann::json& val) { return m_{{name}}; } -void {{classname}}::{{setter}}({{{dataType}}} value) +void {{classname}}::{{setter}}({{{dataType}}}& value) { m_{{name}} = value; {{^required}}m_{{name}}IsSet = true;{{/required}} diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.cpp b/samples/server/petstore/cpp-pistache/api/PetApi.cpp index 90d1e18c168b..c06c5fb1870b 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/PetApi.cpp @@ -20,24 +20,24 @@ namespace api { using namespace org::openapitools::server::model; PetApi::PetApi(Pistache::Address addr) - : httpEndpoint(std::make_shared(addr)) + : httpEndpoint(addr) { }; void PetApi::init(size_t thr = 2) { auto opts = Pistache::Http::Endpoint::options() .threads(thr) .flags(Pistache::Tcp::Options::InstallSignalHandler); - httpEndpoint->init(opts); + httpEndpoint.init(opts); setupRoutes(); } void PetApi::start() { - httpEndpoint->setHandler(router.handler()); - httpEndpoint->serve(); + httpEndpoint.setHandler(router.handler()); + httpEndpoint.serve(); } void PetApi::shutdown() { - httpEndpoint->shutdown(); + httpEndpoint.shutdown(); } void PetApi::setupRoutes() { diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.h b/samples/server/petstore/cpp-pistache/api/PetApi.h index f717727713ef..4300dec560c1 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.h +++ b/samples/server/petstore/cpp-pistache/api/PetApi.h @@ -60,7 +60,7 @@ class PetApi { void upload_file_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); void pet_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr httpEndpoint; + Pistache::Http::Endpoint httpEndpoint; Pistache::Rest::Router router; diff --git a/samples/server/petstore/cpp-pistache/api/StoreApi.cpp b/samples/server/petstore/cpp-pistache/api/StoreApi.cpp index ed8d2bb35687..eea7fe58ea9a 100644 --- a/samples/server/petstore/cpp-pistache/api/StoreApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/StoreApi.cpp @@ -20,24 +20,24 @@ namespace api { using namespace org::openapitools::server::model; StoreApi::StoreApi(Pistache::Address addr) - : httpEndpoint(std::make_shared(addr)) + : httpEndpoint(addr) { }; void StoreApi::init(size_t thr = 2) { auto opts = Pistache::Http::Endpoint::options() .threads(thr) .flags(Pistache::Tcp::Options::InstallSignalHandler); - httpEndpoint->init(opts); + httpEndpoint.init(opts); setupRoutes(); } void StoreApi::start() { - httpEndpoint->setHandler(router.handler()); - httpEndpoint->serve(); + httpEndpoint.setHandler(router.handler()); + httpEndpoint.serve(); } void StoreApi::shutdown() { - httpEndpoint->shutdown(); + httpEndpoint.shutdown(); } void StoreApi::setupRoutes() { diff --git a/samples/server/petstore/cpp-pistache/api/StoreApi.h b/samples/server/petstore/cpp-pistache/api/StoreApi.h index e8d26ee75f21..7068fcde6206 100644 --- a/samples/server/petstore/cpp-pistache/api/StoreApi.h +++ b/samples/server/petstore/cpp-pistache/api/StoreApi.h @@ -56,7 +56,7 @@ class StoreApi { void place_order_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); void store_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr httpEndpoint; + Pistache::Http::Endpoint httpEndpoint; Pistache::Rest::Router router; diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.cpp b/samples/server/petstore/cpp-pistache/api/UserApi.cpp index a2889d6a70a4..eade7bdf8b75 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/UserApi.cpp @@ -20,24 +20,24 @@ namespace api { using namespace org::openapitools::server::model; UserApi::UserApi(Pistache::Address addr) - : httpEndpoint(std::make_shared(addr)) + : httpEndpoint(addr) { }; void UserApi::init(size_t thr = 2) { auto opts = Pistache::Http::Endpoint::options() .threads(thr) .flags(Pistache::Tcp::Options::InstallSignalHandler); - httpEndpoint->init(opts); + httpEndpoint.init(opts); setupRoutes(); } void UserApi::start() { - httpEndpoint->setHandler(router.handler()); - httpEndpoint->serve(); + httpEndpoint.setHandler(router.handler()); + httpEndpoint.serve(); } void UserApi::shutdown() { - httpEndpoint->shutdown(); + httpEndpoint.shutdown(); } void UserApi::setupRoutes() { diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.h b/samples/server/petstore/cpp-pistache/api/UserApi.h index 375ba3b401eb..08739d309ba6 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.h +++ b/samples/server/petstore/cpp-pistache/api/UserApi.h @@ -60,7 +60,7 @@ class UserApi { void update_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); void user_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr httpEndpoint; + Pistache::Http::Endpoint httpEndpoint; Pistache::Rest::Router router; diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp index 5cab25713d99..89be56b32ae6 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp @@ -83,7 +83,7 @@ int32_t ApiResponse::getCode() const { return m_Code; } -void ApiResponse::setCode(int32_t value) +void ApiResponse::setCode(int32_t& value) { m_Code = value; m_CodeIsSet = true; @@ -100,7 +100,7 @@ std::string ApiResponse::getType() const { return m_Type; } -void ApiResponse::setType(std::string value) +void ApiResponse::setType(std::string& value) { m_Type = value; m_TypeIsSet = true; @@ -117,7 +117,7 @@ std::string ApiResponse::getMessage() const { return m_Message; } -void ApiResponse::setMessage(std::string value) +void ApiResponse::setMessage(std::string& value) { m_Message = value; m_MessageIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.h b/samples/server/petstore/cpp-pistache/model/ApiResponse.h index dbdbf29b8267..e5f6ccb4c318 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.h +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.h @@ -53,21 +53,21 @@ class ApiResponse /// /// int32_t getCode() const; - void setCode(int32_t value); + void setCode(int32_t& value); bool codeIsSet() const; void unsetCode(); /// /// /// std::string getType() const; - void setType(std::string value); + void setType(std::string& value); bool typeIsSet() const; void unsetType(); /// /// /// std::string getMessage() const; - void setMessage(std::string value); + void setMessage(std::string& value); bool messageIsSet() const; void unsetMessage(); diff --git a/samples/server/petstore/cpp-pistache/model/Category.cpp b/samples/server/petstore/cpp-pistache/model/Category.cpp index d528f343d7e7..30a9f9ef3a9f 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache/model/Category.cpp @@ -72,7 +72,7 @@ int64_t Category::getId() const { return m_Id; } -void Category::setId(int64_t value) +void Category::setId(int64_t& value) { m_Id = value; m_IdIsSet = true; @@ -89,7 +89,7 @@ std::string Category::getName() const { return m_Name; } -void Category::setName(std::string value) +void Category::setName(std::string& value) { m_Name = value; m_NameIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Category.h b/samples/server/petstore/cpp-pistache/model/Category.h index 6e3885e2d739..4dcd8bc32f31 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.h +++ b/samples/server/petstore/cpp-pistache/model/Category.h @@ -53,14 +53,14 @@ class Category /// /// int64_t getId() const; - void setId(int64_t value); + void setId(int64_t& value); bool idIsSet() const; void unsetId(); /// /// /// std::string getName() const; - void setName(std::string value); + void setName(std::string& value); bool nameIsSet() const; void unsetName(); diff --git a/samples/server/petstore/cpp-pistache/model/ModelBase.cpp b/samples/server/petstore/cpp-pistache/model/ModelBase.cpp index dca7f7198fff..052294a9919c 100644 --- a/samples/server/petstore/cpp-pistache/model/ModelBase.cpp +++ b/samples/server/petstore/cpp-pistache/model/ModelBase.cpp @@ -55,9 +55,9 @@ bool ModelBase::toJson( bool value ) return value; } -nlohmann::json ModelBase::toJson( std::shared_ptr content ) +nlohmann::json ModelBase::toJson(ModelBase content ) { - return content.get() ? content->toJson() : nlohmann::json(); + return content.toJson(); } } diff --git a/samples/server/petstore/cpp-pistache/model/ModelBase.h b/samples/server/petstore/cpp-pistache/model/ModelBase.h index 309184319875..6dbe7524522e 100644 --- a/samples/server/petstore/cpp-pistache/model/ModelBase.h +++ b/samples/server/petstore/cpp-pistache/model/ModelBase.h @@ -45,7 +45,7 @@ class ModelBase static int64_t toJson( int64_t value ); static double toJson( double value ); static bool toJson( bool value ); - static nlohmann::json toJson( std::shared_ptr content ); + static nlohmann::json toJson(ModelBase content ); }; diff --git a/samples/server/petstore/cpp-pistache/model/Order.cpp b/samples/server/petstore/cpp-pistache/model/Order.cpp index 712705e313ee..acf23253c011 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.cpp +++ b/samples/server/petstore/cpp-pistache/model/Order.cpp @@ -113,7 +113,7 @@ int64_t Order::getId() const { return m_Id; } -void Order::setId(int64_t value) +void Order::setId(int64_t& value) { m_Id = value; m_IdIsSet = true; @@ -130,7 +130,7 @@ int64_t Order::getPetId() const { return m_PetId; } -void Order::setPetId(int64_t value) +void Order::setPetId(int64_t& value) { m_PetId = value; m_PetIdIsSet = true; @@ -147,7 +147,7 @@ int32_t Order::getQuantity() const { return m_Quantity; } -void Order::setQuantity(int32_t value) +void Order::setQuantity(int32_t& value) { m_Quantity = value; m_QuantityIsSet = true; @@ -164,7 +164,7 @@ std::string Order::getShipDate() const { return m_ShipDate; } -void Order::setShipDate(std::string value) +void Order::setShipDate(std::string& value) { m_ShipDate = value; m_ShipDateIsSet = true; @@ -181,7 +181,7 @@ std::string Order::getStatus() const { return m_Status; } -void Order::setStatus(std::string value) +void Order::setStatus(std::string& value) { m_Status = value; m_StatusIsSet = true; @@ -198,7 +198,7 @@ bool Order::isComplete() const { return m_Complete; } -void Order::setComplete(bool value) +void Order::setComplete(bool& value) { m_Complete = value; m_CompleteIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Order.h b/samples/server/petstore/cpp-pistache/model/Order.h index bc5776715541..3473110417c9 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.h +++ b/samples/server/petstore/cpp-pistache/model/Order.h @@ -53,42 +53,42 @@ class Order /// /// int64_t getId() const; - void setId(int64_t value); + void setId(int64_t& value); bool idIsSet() const; void unsetId(); /// /// /// int64_t getPetId() const; - void setPetId(int64_t value); + void setPetId(int64_t& value); bool petIdIsSet() const; void unsetPetId(); /// /// /// int32_t getQuantity() const; - void setQuantity(int32_t value); + void setQuantity(int32_t& value); bool quantityIsSet() const; void unsetQuantity(); /// /// /// std::string getShipDate() const; - void setShipDate(std::string value); + void setShipDate(std::string& value); bool shipDateIsSet() const; void unsetShipDate(); /// /// Order Status /// std::string getStatus() const; - void setStatus(std::string value); + void setStatus(std::string& value); bool statusIsSet() const; void unsetStatus(); /// /// /// bool isComplete() const; - void setComplete(bool value); + void setComplete(bool& value); bool completeIsSet() const; void unsetComplete(); diff --git a/samples/server/petstore/cpp-pistache/model/Pet.cpp b/samples/server/petstore/cpp-pistache/model/Pet.cpp index 3e24bf430742..724c365c503b 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.cpp +++ b/samples/server/petstore/cpp-pistache/model/Pet.cpp @@ -92,7 +92,7 @@ void Pet::fromJson(nlohmann::json& val) if(!val["category"].is_null()) { Category newItem(Category()); - newItem->fromJson(val["category"]); + newItem.fromJson(val["category"]); setCategory( newItem ); } @@ -122,7 +122,7 @@ void Pet::fromJson(nlohmann::json& val) else { Tag newItem(Tag()); - newItem->fromJson(item); + newItem.fromJson(item); m_Tags.push_back( newItem ); } @@ -142,7 +142,7 @@ int64_t Pet::getId() const { return m_Id; } -void Pet::setId(int64_t value) +void Pet::setId(int64_t& value) { m_Id = value; m_IdIsSet = true; @@ -159,7 +159,7 @@ Category Pet::getCategory() const { return m_Category; } -void Pet::setCategory(Category value) +void Pet::setCategory(Category& value) { m_Category = value; m_CategoryIsSet = true; @@ -176,7 +176,7 @@ std::string Pet::getName() const { return m_Name; } -void Pet::setName(std::string value) +void Pet::setName(std::string& value) { m_Name = value; @@ -201,7 +201,7 @@ std::string Pet::getStatus() const { return m_Status; } -void Pet::setStatus(std::string value) +void Pet::setStatus(std::string& value) { m_Status = value; m_StatusIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Pet.h b/samples/server/petstore/cpp-pistache/model/Pet.h index 455baf5a1e78..71b73cbe382d 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.h +++ b/samples/server/petstore/cpp-pistache/model/Pet.h @@ -56,21 +56,21 @@ class Pet /// /// int64_t getId() const; - void setId(int64_t value); + void setId(int64_t& value); bool idIsSet() const; void unsetId(); /// /// /// Category getCategory() const; - void setCategory(Category value); + void setCategory(Category& value); bool categoryIsSet() const; void unsetCategory(); /// /// /// std::string getName() const; - void setName(std::string value); + void setName(std::string& value); /// /// /// @@ -85,7 +85,7 @@ class Pet /// pet status in the store /// std::string getStatus() const; - void setStatus(std::string value); + void setStatus(std::string& value); bool statusIsSet() const; void unsetStatus(); diff --git a/samples/server/petstore/cpp-pistache/model/Tag.cpp b/samples/server/petstore/cpp-pistache/model/Tag.cpp index 9091c15cfd95..3fcf642402a8 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.cpp +++ b/samples/server/petstore/cpp-pistache/model/Tag.cpp @@ -72,7 +72,7 @@ int64_t Tag::getId() const { return m_Id; } -void Tag::setId(int64_t value) +void Tag::setId(int64_t& value) { m_Id = value; m_IdIsSet = true; @@ -89,7 +89,7 @@ std::string Tag::getName() const { return m_Name; } -void Tag::setName(std::string value) +void Tag::setName(std::string& value) { m_Name = value; m_NameIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Tag.h b/samples/server/petstore/cpp-pistache/model/Tag.h index 08a4fec456d4..b15ac44c26ac 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.h +++ b/samples/server/petstore/cpp-pistache/model/Tag.h @@ -53,14 +53,14 @@ class Tag /// /// int64_t getId() const; - void setId(int64_t value); + void setId(int64_t& value); bool idIsSet() const; void unsetId(); /// /// /// std::string getName() const; - void setName(std::string value); + void setName(std::string& value); bool nameIsSet() const; void unsetName(); diff --git a/samples/server/petstore/cpp-pistache/model/User.cpp b/samples/server/petstore/cpp-pistache/model/User.cpp index 88e159c196f7..45a389cec505 100644 --- a/samples/server/petstore/cpp-pistache/model/User.cpp +++ b/samples/server/petstore/cpp-pistache/model/User.cpp @@ -137,7 +137,7 @@ int64_t User::getId() const { return m_Id; } -void User::setId(int64_t value) +void User::setId(int64_t& value) { m_Id = value; m_IdIsSet = true; @@ -154,7 +154,7 @@ std::string User::getUsername() const { return m_Username; } -void User::setUsername(std::string value) +void User::setUsername(std::string& value) { m_Username = value; m_UsernameIsSet = true; @@ -171,7 +171,7 @@ std::string User::getFirstName() const { return m_FirstName; } -void User::setFirstName(std::string value) +void User::setFirstName(std::string& value) { m_FirstName = value; m_FirstNameIsSet = true; @@ -188,7 +188,7 @@ std::string User::getLastName() const { return m_LastName; } -void User::setLastName(std::string value) +void User::setLastName(std::string& value) { m_LastName = value; m_LastNameIsSet = true; @@ -205,7 +205,7 @@ std::string User::getEmail() const { return m_Email; } -void User::setEmail(std::string value) +void User::setEmail(std::string& value) { m_Email = value; m_EmailIsSet = true; @@ -222,7 +222,7 @@ std::string User::getPassword() const { return m_Password; } -void User::setPassword(std::string value) +void User::setPassword(std::string& value) { m_Password = value; m_PasswordIsSet = true; @@ -239,7 +239,7 @@ std::string User::getPhone() const { return m_Phone; } -void User::setPhone(std::string value) +void User::setPhone(std::string& value) { m_Phone = value; m_PhoneIsSet = true; @@ -256,7 +256,7 @@ int32_t User::getUserStatus() const { return m_UserStatus; } -void User::setUserStatus(int32_t value) +void User::setUserStatus(int32_t& value) { m_UserStatus = value; m_UserStatusIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/User.h b/samples/server/petstore/cpp-pistache/model/User.h index e8dab49531d3..cced46c9beb3 100644 --- a/samples/server/petstore/cpp-pistache/model/User.h +++ b/samples/server/petstore/cpp-pistache/model/User.h @@ -53,56 +53,56 @@ class User /// /// int64_t getId() const; - void setId(int64_t value); + void setId(int64_t& value); bool idIsSet() const; void unsetId(); /// /// /// std::string getUsername() const; - void setUsername(std::string value); + void setUsername(std::string& value); bool usernameIsSet() const; void unsetUsername(); /// /// /// std::string getFirstName() const; - void setFirstName(std::string value); + void setFirstName(std::string& value); bool firstNameIsSet() const; void unsetFirstName(); /// /// /// std::string getLastName() const; - void setLastName(std::string value); + void setLastName(std::string& value); bool lastNameIsSet() const; void unsetLastName(); /// /// /// std::string getEmail() const; - void setEmail(std::string value); + void setEmail(std::string& value); bool emailIsSet() const; void unsetEmail(); /// /// /// std::string getPassword() const; - void setPassword(std::string value); + void setPassword(std::string& value); bool passwordIsSet() const; void unsetPassword(); /// /// /// std::string getPhone() const; - void setPhone(std::string value); + void setPhone(std::string& value); bool phoneIsSet() const; void unsetPhone(); /// /// User Status /// int32_t getUserStatus() const; - void setUserStatus(int32_t value); + void setUserStatus(int32_t& value); bool userStatusIsSet() const; void unsetUserStatus(); From 91e795fb4e3a85c4288537326fe29e720aca88ed Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sun, 10 Jun 2018 16:10:16 +0200 Subject: [PATCH 07/10] Added const to all model setter functions, and reference to all params in setters that are not primitives --- .../cpp-pistache-server/model-header.mustache | 2 +- .../cpp-pistache-server/model-source.mustache | 2 +- .../petstore/cpp-pistache/model/ApiResponse.cpp | 6 +++--- .../petstore/cpp-pistache/model/ApiResponse.h | 6 +++--- .../petstore/cpp-pistache/model/Category.cpp | 4 ++-- .../petstore/cpp-pistache/model/Category.h | 4 ++-- .../server/petstore/cpp-pistache/model/Order.cpp | 12 ++++++------ .../server/petstore/cpp-pistache/model/Order.h | 12 ++++++------ .../server/petstore/cpp-pistache/model/Pet.cpp | 8 ++++---- samples/server/petstore/cpp-pistache/model/Pet.h | 8 ++++---- .../server/petstore/cpp-pistache/model/Tag.cpp | 4 ++-- samples/server/petstore/cpp-pistache/model/Tag.h | 4 ++-- .../server/petstore/cpp-pistache/model/User.cpp | 16 ++++++++-------- .../server/petstore/cpp-pistache/model/User.h | 16 ++++++++-------- 14 files changed, 52 insertions(+), 52 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache index f0c19afefed2..7b3647a4c3b6 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache @@ -45,7 +45,7 @@ public: /// {{^isNotContainer}}{{{dataType}}}& {{getter}}(); {{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{getter}}() const; - void {{setter}}({{{dataType}}}& value); + void {{setter}}({{{dataType}}} const {{^isPrimitiveType}}&{{/isPrimitiveType}} value); {{/isNotContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const; void unset{{name}}(); {{/required}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache index fb1a9d73c2b1..b2434df4670c 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache @@ -119,7 +119,7 @@ void {{classname}}::fromJson(nlohmann::json& val) { return m_{{name}}; } -void {{classname}}::{{setter}}({{{dataType}}}& value) +void {{classname}}::{{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value) { m_{{name}} = value; {{^required}}m_{{name}}IsSet = true;{{/required}} diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp index 89be56b32ae6..bb07343a1b49 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp @@ -83,7 +83,7 @@ int32_t ApiResponse::getCode() const { return m_Code; } -void ApiResponse::setCode(int32_t& value) +void ApiResponse::setCode(int32_t const value) { m_Code = value; m_CodeIsSet = true; @@ -100,7 +100,7 @@ std::string ApiResponse::getType() const { return m_Type; } -void ApiResponse::setType(std::string& value) +void ApiResponse::setType(std::string const& value) { m_Type = value; m_TypeIsSet = true; @@ -117,7 +117,7 @@ std::string ApiResponse::getMessage() const { return m_Message; } -void ApiResponse::setMessage(std::string& value) +void ApiResponse::setMessage(std::string const& value) { m_Message = value; m_MessageIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.h b/samples/server/petstore/cpp-pistache/model/ApiResponse.h index e5f6ccb4c318..4d1c4481d301 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.h +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.h @@ -53,21 +53,21 @@ class ApiResponse /// /// int32_t getCode() const; - void setCode(int32_t& value); + void setCode(int32_t const value); bool codeIsSet() const; void unsetCode(); /// /// /// std::string getType() const; - void setType(std::string& value); + void setType(std::string const & value); bool typeIsSet() const; void unsetType(); /// /// /// std::string getMessage() const; - void setMessage(std::string& value); + void setMessage(std::string const & value); bool messageIsSet() const; void unsetMessage(); diff --git a/samples/server/petstore/cpp-pistache/model/Category.cpp b/samples/server/petstore/cpp-pistache/model/Category.cpp index 30a9f9ef3a9f..a1d24fdab57f 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache/model/Category.cpp @@ -72,7 +72,7 @@ int64_t Category::getId() const { return m_Id; } -void Category::setId(int64_t& value) +void Category::setId(int64_t const value) { m_Id = value; m_IdIsSet = true; @@ -89,7 +89,7 @@ std::string Category::getName() const { return m_Name; } -void Category::setName(std::string& value) +void Category::setName(std::string const& value) { m_Name = value; m_NameIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Category.h b/samples/server/petstore/cpp-pistache/model/Category.h index 4dcd8bc32f31..53fd493cc39a 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.h +++ b/samples/server/petstore/cpp-pistache/model/Category.h @@ -53,14 +53,14 @@ class Category /// /// int64_t getId() const; - void setId(int64_t& value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// std::string getName() const; - void setName(std::string& value); + void setName(std::string const & value); bool nameIsSet() const; void unsetName(); diff --git a/samples/server/petstore/cpp-pistache/model/Order.cpp b/samples/server/petstore/cpp-pistache/model/Order.cpp index acf23253c011..fb3fde19d3a0 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.cpp +++ b/samples/server/petstore/cpp-pistache/model/Order.cpp @@ -113,7 +113,7 @@ int64_t Order::getId() const { return m_Id; } -void Order::setId(int64_t& value) +void Order::setId(int64_t const value) { m_Id = value; m_IdIsSet = true; @@ -130,7 +130,7 @@ int64_t Order::getPetId() const { return m_PetId; } -void Order::setPetId(int64_t& value) +void Order::setPetId(int64_t const value) { m_PetId = value; m_PetIdIsSet = true; @@ -147,7 +147,7 @@ int32_t Order::getQuantity() const { return m_Quantity; } -void Order::setQuantity(int32_t& value) +void Order::setQuantity(int32_t const value) { m_Quantity = value; m_QuantityIsSet = true; @@ -164,7 +164,7 @@ std::string Order::getShipDate() const { return m_ShipDate; } -void Order::setShipDate(std::string& value) +void Order::setShipDate(std::string const& value) { m_ShipDate = value; m_ShipDateIsSet = true; @@ -181,7 +181,7 @@ std::string Order::getStatus() const { return m_Status; } -void Order::setStatus(std::string& value) +void Order::setStatus(std::string const& value) { m_Status = value; m_StatusIsSet = true; @@ -198,7 +198,7 @@ bool Order::isComplete() const { return m_Complete; } -void Order::setComplete(bool& value) +void Order::setComplete(bool const value) { m_Complete = value; m_CompleteIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Order.h b/samples/server/petstore/cpp-pistache/model/Order.h index 3473110417c9..ee763a90d75c 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.h +++ b/samples/server/petstore/cpp-pistache/model/Order.h @@ -53,42 +53,42 @@ class Order /// /// int64_t getId() const; - void setId(int64_t& value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// int64_t getPetId() const; - void setPetId(int64_t& value); + void setPetId(int64_t const value); bool petIdIsSet() const; void unsetPetId(); /// /// /// int32_t getQuantity() const; - void setQuantity(int32_t& value); + void setQuantity(int32_t const value); bool quantityIsSet() const; void unsetQuantity(); /// /// /// std::string getShipDate() const; - void setShipDate(std::string& value); + void setShipDate(std::string const & value); bool shipDateIsSet() const; void unsetShipDate(); /// /// Order Status /// std::string getStatus() const; - void setStatus(std::string& value); + void setStatus(std::string const & value); bool statusIsSet() const; void unsetStatus(); /// /// /// bool isComplete() const; - void setComplete(bool& value); + void setComplete(bool const value); bool completeIsSet() const; void unsetComplete(); diff --git a/samples/server/petstore/cpp-pistache/model/Pet.cpp b/samples/server/petstore/cpp-pistache/model/Pet.cpp index 724c365c503b..2c200a8db2c1 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.cpp +++ b/samples/server/petstore/cpp-pistache/model/Pet.cpp @@ -142,7 +142,7 @@ int64_t Pet::getId() const { return m_Id; } -void Pet::setId(int64_t& value) +void Pet::setId(int64_t const value) { m_Id = value; m_IdIsSet = true; @@ -159,7 +159,7 @@ Category Pet::getCategory() const { return m_Category; } -void Pet::setCategory(Category& value) +void Pet::setCategory(Category const& value) { m_Category = value; m_CategoryIsSet = true; @@ -176,7 +176,7 @@ std::string Pet::getName() const { return m_Name; } -void Pet::setName(std::string& value) +void Pet::setName(std::string const& value) { m_Name = value; @@ -201,7 +201,7 @@ std::string Pet::getStatus() const { return m_Status; } -void Pet::setStatus(std::string& value) +void Pet::setStatus(std::string const& value) { m_Status = value; m_StatusIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Pet.h b/samples/server/petstore/cpp-pistache/model/Pet.h index 71b73cbe382d..6243a5cdd24b 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.h +++ b/samples/server/petstore/cpp-pistache/model/Pet.h @@ -56,21 +56,21 @@ class Pet /// /// int64_t getId() const; - void setId(int64_t& value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// Category getCategory() const; - void setCategory(Category& value); + void setCategory(Category const & value); bool categoryIsSet() const; void unsetCategory(); /// /// /// std::string getName() const; - void setName(std::string& value); + void setName(std::string const & value); /// /// /// @@ -85,7 +85,7 @@ class Pet /// pet status in the store /// std::string getStatus() const; - void setStatus(std::string& value); + void setStatus(std::string const & value); bool statusIsSet() const; void unsetStatus(); diff --git a/samples/server/petstore/cpp-pistache/model/Tag.cpp b/samples/server/petstore/cpp-pistache/model/Tag.cpp index 3fcf642402a8..1cbc344ba52a 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.cpp +++ b/samples/server/petstore/cpp-pistache/model/Tag.cpp @@ -72,7 +72,7 @@ int64_t Tag::getId() const { return m_Id; } -void Tag::setId(int64_t& value) +void Tag::setId(int64_t const value) { m_Id = value; m_IdIsSet = true; @@ -89,7 +89,7 @@ std::string Tag::getName() const { return m_Name; } -void Tag::setName(std::string& value) +void Tag::setName(std::string const& value) { m_Name = value; m_NameIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/Tag.h b/samples/server/petstore/cpp-pistache/model/Tag.h index b15ac44c26ac..399e333e7fc9 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.h +++ b/samples/server/petstore/cpp-pistache/model/Tag.h @@ -53,14 +53,14 @@ class Tag /// /// int64_t getId() const; - void setId(int64_t& value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// std::string getName() const; - void setName(std::string& value); + void setName(std::string const & value); bool nameIsSet() const; void unsetName(); diff --git a/samples/server/petstore/cpp-pistache/model/User.cpp b/samples/server/petstore/cpp-pistache/model/User.cpp index 45a389cec505..e0f4defae3e1 100644 --- a/samples/server/petstore/cpp-pistache/model/User.cpp +++ b/samples/server/petstore/cpp-pistache/model/User.cpp @@ -137,7 +137,7 @@ int64_t User::getId() const { return m_Id; } -void User::setId(int64_t& value) +void User::setId(int64_t const value) { m_Id = value; m_IdIsSet = true; @@ -154,7 +154,7 @@ std::string User::getUsername() const { return m_Username; } -void User::setUsername(std::string& value) +void User::setUsername(std::string const& value) { m_Username = value; m_UsernameIsSet = true; @@ -171,7 +171,7 @@ std::string User::getFirstName() const { return m_FirstName; } -void User::setFirstName(std::string& value) +void User::setFirstName(std::string const& value) { m_FirstName = value; m_FirstNameIsSet = true; @@ -188,7 +188,7 @@ std::string User::getLastName() const { return m_LastName; } -void User::setLastName(std::string& value) +void User::setLastName(std::string const& value) { m_LastName = value; m_LastNameIsSet = true; @@ -205,7 +205,7 @@ std::string User::getEmail() const { return m_Email; } -void User::setEmail(std::string& value) +void User::setEmail(std::string const& value) { m_Email = value; m_EmailIsSet = true; @@ -222,7 +222,7 @@ std::string User::getPassword() const { return m_Password; } -void User::setPassword(std::string& value) +void User::setPassword(std::string const& value) { m_Password = value; m_PasswordIsSet = true; @@ -239,7 +239,7 @@ std::string User::getPhone() const { return m_Phone; } -void User::setPhone(std::string& value) +void User::setPhone(std::string const& value) { m_Phone = value; m_PhoneIsSet = true; @@ -256,7 +256,7 @@ int32_t User::getUserStatus() const { return m_UserStatus; } -void User::setUserStatus(int32_t& value) +void User::setUserStatus(int32_t const value) { m_UserStatus = value; m_UserStatusIsSet = true; diff --git a/samples/server/petstore/cpp-pistache/model/User.h b/samples/server/petstore/cpp-pistache/model/User.h index cced46c9beb3..19443e79510f 100644 --- a/samples/server/petstore/cpp-pistache/model/User.h +++ b/samples/server/petstore/cpp-pistache/model/User.h @@ -53,56 +53,56 @@ class User /// /// int64_t getId() const; - void setId(int64_t& value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// std::string getUsername() const; - void setUsername(std::string& value); + void setUsername(std::string const & value); bool usernameIsSet() const; void unsetUsername(); /// /// /// std::string getFirstName() const; - void setFirstName(std::string& value); + void setFirstName(std::string const & value); bool firstNameIsSet() const; void unsetFirstName(); /// /// /// std::string getLastName() const; - void setLastName(std::string& value); + void setLastName(std::string const & value); bool lastNameIsSet() const; void unsetLastName(); /// /// /// std::string getEmail() const; - void setEmail(std::string& value); + void setEmail(std::string const & value); bool emailIsSet() const; void unsetEmail(); /// /// /// std::string getPassword() const; - void setPassword(std::string& value); + void setPassword(std::string const & value); bool passwordIsSet() const; void unsetPassword(); /// /// /// std::string getPhone() const; - void setPhone(std::string& value); + void setPhone(std::string const & value); bool phoneIsSet() const; void unsetPhone(); /// /// User Status /// int32_t getUserStatus() const; - void setUserStatus(int32_t& value); + void setUserStatus(int32_t const value); bool userStatusIsSet() const; void unsetUserStatus(); From 6fb317da94e1c0d9d7f343c1a742c883fdf97a10 Mon Sep 17 00:00:00 2001 From: stkrwork Date: Sun, 10 Jun 2018 16:20:53 +0200 Subject: [PATCH 08/10] Refactored modelbase --- .../cpp-pistache-server/model-header.mustache | 2 +- .../modelbase-header.mustache | 14 +++++++------- .../modelbase-source.mustache | 12 ++++++------ .../petstore/cpp-pistache/model/ApiResponse.h | 6 +++--- .../petstore/cpp-pistache/model/Category.h | 4 ++-- .../petstore/cpp-pistache/model/ModelBase.cpp | 12 ++++++------ .../petstore/cpp-pistache/model/ModelBase.h | 14 +++++++------- .../server/petstore/cpp-pistache/model/Order.h | 12 ++++++------ samples/server/petstore/cpp-pistache/model/Pet.h | 8 ++++---- samples/server/petstore/cpp-pistache/model/Tag.h | 4 ++-- .../server/petstore/cpp-pistache/model/User.h | 16 ++++++++-------- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache index 7b3647a4c3b6..3efd24758f58 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache @@ -45,7 +45,7 @@ public: /// {{^isNotContainer}}{{{dataType}}}& {{getter}}(); {{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{getter}}() const; - void {{setter}}({{{dataType}}} const {{^isPrimitiveType}}&{{/isPrimitiveType}} value); + void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value); {{/isNotContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const; void unset{{name}}(); {{/required}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache index 1f022f34e7fd..f4f000b14ff4 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache @@ -28,13 +28,13 @@ public: virtual nlohmann::json toJson() const = 0; virtual void fromJson(nlohmann::json& json) = 0; - static std::string toJson( const std::string& value ); - static std::string toJson( const std::time_t& value ); - static int32_t toJson( int32_t value ); - static int64_t toJson( int64_t value ); - static double toJson( double value ); - static bool toJson( bool value ); - static nlohmann::json toJson(ModelBase content ); + static std::string toJson( std::string const& value ) const; + static std::string toJson( std::time_t const& value ) const; + static int32_t toJson( int32_t const value ) const; + static int64_t toJson( int64_t const value ) const; + static double toJson( double const value ) const; + static bool toJson( bool const value ) const; + static nlohmann::json toJson(ModelBase const& content ); }; diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache index 87b56ee00361..a5ec9406c424 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache @@ -12,34 +12,34 @@ ModelBase::~ModelBase() { } -std::string ModelBase::toJson( const std::string& value ) +std::string ModelBase::toJson( std::string const& value ) { return value; } -std::string ModelBase::toJson( const std::time_t& value ) +std::string ModelBase::toJson( std::time_t const& value ) { char buf[sizeof "2011-10-08T07:07:09Z"]; strftime(buf, sizeof buf, "%FT%TZ", gmtime(&value)); return buf; } -int32_t ModelBase::toJson( int32_t value ) +int32_t ModelBase::toJson( int32_t const value ) { return value; } -int64_t ModelBase::toJson( int64_t value ) +int64_t ModelBase::toJson( int64_t const value ) { return value; } -double ModelBase::toJson( double value ) +double ModelBase::toJson( double const value ) { return value; } -bool ModelBase::toJson( bool value ) +bool ModelBase::toJson( bool const value ) { return value; } diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.h b/samples/server/petstore/cpp-pistache/model/ApiResponse.h index 4d1c4481d301..51c96e3838cb 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.h +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.h @@ -53,21 +53,21 @@ class ApiResponse /// /// int32_t getCode() const; - void setCode(int32_t const value); + void setCode(int32_t const value); bool codeIsSet() const; void unsetCode(); /// /// /// std::string getType() const; - void setType(std::string const & value); + void setType(std::string const& value); bool typeIsSet() const; void unsetType(); /// /// /// std::string getMessage() const; - void setMessage(std::string const & value); + void setMessage(std::string const& value); bool messageIsSet() const; void unsetMessage(); diff --git a/samples/server/petstore/cpp-pistache/model/Category.h b/samples/server/petstore/cpp-pistache/model/Category.h index 53fd493cc39a..19b951a44e77 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.h +++ b/samples/server/petstore/cpp-pistache/model/Category.h @@ -53,14 +53,14 @@ class Category /// /// int64_t getId() const; - void setId(int64_t const value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// std::string getName() const; - void setName(std::string const & value); + void setName(std::string const& value); bool nameIsSet() const; void unsetName(); diff --git a/samples/server/petstore/cpp-pistache/model/ModelBase.cpp b/samples/server/petstore/cpp-pistache/model/ModelBase.cpp index 052294a9919c..d8c2437c6ff0 100644 --- a/samples/server/petstore/cpp-pistache/model/ModelBase.cpp +++ b/samples/server/petstore/cpp-pistache/model/ModelBase.cpp @@ -23,34 +23,34 @@ ModelBase::~ModelBase() { } -std::string ModelBase::toJson( const std::string& value ) +std::string ModelBase::toJson( std::string const& value ) { return value; } -std::string ModelBase::toJson( const std::time_t& value ) +std::string ModelBase::toJson( std::time_t const& value ) { char buf[sizeof "2011-10-08T07:07:09Z"]; strftime(buf, sizeof buf, "%FT%TZ", gmtime(&value)); return buf; } -int32_t ModelBase::toJson( int32_t value ) +int32_t ModelBase::toJson( int32_t const value ) { return value; } -int64_t ModelBase::toJson( int64_t value ) +int64_t ModelBase::toJson( int64_t const value ) { return value; } -double ModelBase::toJson( double value ) +double ModelBase::toJson( double const value ) { return value; } -bool ModelBase::toJson( bool value ) +bool ModelBase::toJson( bool const value ) { return value; } diff --git a/samples/server/petstore/cpp-pistache/model/ModelBase.h b/samples/server/petstore/cpp-pistache/model/ModelBase.h index 6dbe7524522e..1b5495b28009 100644 --- a/samples/server/petstore/cpp-pistache/model/ModelBase.h +++ b/samples/server/petstore/cpp-pistache/model/ModelBase.h @@ -39,13 +39,13 @@ class ModelBase virtual nlohmann::json toJson() const = 0; virtual void fromJson(nlohmann::json& json) = 0; - static std::string toJson( const std::string& value ); - static std::string toJson( const std::time_t& value ); - static int32_t toJson( int32_t value ); - static int64_t toJson( int64_t value ); - static double toJson( double value ); - static bool toJson( bool value ); - static nlohmann::json toJson(ModelBase content ); + static std::string toJson( std::string const& value ) const; + static std::string toJson( std::time_t const& value ) const; + static int32_t toJson( int32_t const value ) const; + static int64_t toJson( int64_t const value ) const; + static double toJson( double const value ) const; + static bool toJson( bool const value ) const; + static nlohmann::json toJson(ModelBase const& content ); }; diff --git a/samples/server/petstore/cpp-pistache/model/Order.h b/samples/server/petstore/cpp-pistache/model/Order.h index ee763a90d75c..548f9de0614b 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.h +++ b/samples/server/petstore/cpp-pistache/model/Order.h @@ -53,42 +53,42 @@ class Order /// /// int64_t getId() const; - void setId(int64_t const value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// int64_t getPetId() const; - void setPetId(int64_t const value); + void setPetId(int64_t const value); bool petIdIsSet() const; void unsetPetId(); /// /// /// int32_t getQuantity() const; - void setQuantity(int32_t const value); + void setQuantity(int32_t const value); bool quantityIsSet() const; void unsetQuantity(); /// /// /// std::string getShipDate() const; - void setShipDate(std::string const & value); + void setShipDate(std::string const& value); bool shipDateIsSet() const; void unsetShipDate(); /// /// Order Status /// std::string getStatus() const; - void setStatus(std::string const & value); + void setStatus(std::string const& value); bool statusIsSet() const; void unsetStatus(); /// /// /// bool isComplete() const; - void setComplete(bool const value); + void setComplete(bool const value); bool completeIsSet() const; void unsetComplete(); diff --git a/samples/server/petstore/cpp-pistache/model/Pet.h b/samples/server/petstore/cpp-pistache/model/Pet.h index 6243a5cdd24b..4117dcf468d5 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.h +++ b/samples/server/petstore/cpp-pistache/model/Pet.h @@ -56,21 +56,21 @@ class Pet /// /// int64_t getId() const; - void setId(int64_t const value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// Category getCategory() const; - void setCategory(Category const & value); + void setCategory(Category const& value); bool categoryIsSet() const; void unsetCategory(); /// /// /// std::string getName() const; - void setName(std::string const & value); + void setName(std::string const& value); /// /// /// @@ -85,7 +85,7 @@ class Pet /// pet status in the store /// std::string getStatus() const; - void setStatus(std::string const & value); + void setStatus(std::string const& value); bool statusIsSet() const; void unsetStatus(); diff --git a/samples/server/petstore/cpp-pistache/model/Tag.h b/samples/server/petstore/cpp-pistache/model/Tag.h index 399e333e7fc9..1b5d79e31c9f 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.h +++ b/samples/server/petstore/cpp-pistache/model/Tag.h @@ -53,14 +53,14 @@ class Tag /// /// int64_t getId() const; - void setId(int64_t const value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// std::string getName() const; - void setName(std::string const & value); + void setName(std::string const& value); bool nameIsSet() const; void unsetName(); diff --git a/samples/server/petstore/cpp-pistache/model/User.h b/samples/server/petstore/cpp-pistache/model/User.h index 19443e79510f..b9a53345866c 100644 --- a/samples/server/petstore/cpp-pistache/model/User.h +++ b/samples/server/petstore/cpp-pistache/model/User.h @@ -53,56 +53,56 @@ class User /// /// int64_t getId() const; - void setId(int64_t const value); + void setId(int64_t const value); bool idIsSet() const; void unsetId(); /// /// /// std::string getUsername() const; - void setUsername(std::string const & value); + void setUsername(std::string const& value); bool usernameIsSet() const; void unsetUsername(); /// /// /// std::string getFirstName() const; - void setFirstName(std::string const & value); + void setFirstName(std::string const& value); bool firstNameIsSet() const; void unsetFirstName(); /// /// /// std::string getLastName() const; - void setLastName(std::string const & value); + void setLastName(std::string const& value); bool lastNameIsSet() const; void unsetLastName(); /// /// /// std::string getEmail() const; - void setEmail(std::string const & value); + void setEmail(std::string const& value); bool emailIsSet() const; void unsetEmail(); /// /// /// std::string getPassword() const; - void setPassword(std::string const & value); + void setPassword(std::string const& value); bool passwordIsSet() const; void unsetPassword(); /// /// /// std::string getPhone() const; - void setPhone(std::string const & value); + void setPhone(std::string const& value); bool phoneIsSet() const; void unsetPhone(); /// /// User Status /// int32_t getUserStatus() const; - void setUserStatus(int32_t const value); + void setUserStatus(int32_t const value); bool userStatusIsSet() const; void unsetUserStatus(); From 3b98e31c8132452cba14cd1e1deb8f54e6ad2ebb Mon Sep 17 00:00:00 2001 From: stkrwork Date: Tue, 12 Jun 2018 14:24:29 +0200 Subject: [PATCH 09/10] Removed const --- .../cpp-pistache-server/modelbase-header.mustache | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache index f4f000b14ff4..2e43bb7b8534 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache @@ -28,12 +28,12 @@ public: virtual nlohmann::json toJson() const = 0; virtual void fromJson(nlohmann::json& json) = 0; - static std::string toJson( std::string const& value ) const; - static std::string toJson( std::time_t const& value ) const; - static int32_t toJson( int32_t const value ) const; - static int64_t toJson( int64_t const value ) const; - static double toJson( double const value ) const; - static bool toJson( bool const value ) const; + static std::string toJson( std::string const& value ); + static std::string toJson( std::time_t const& value ); + static int32_t toJson( int32_t const value ); + static int64_t toJson( int64_t const value ); + static double toJson( double const value ); + static bool toJson( bool const value ); static nlohmann::json toJson(ModelBase const& content ); }; From 38d86e5ed2f45346285be9ab18ffa5eb9c2c0f31 Mon Sep 17 00:00:00 2001 From: stkrwork Date: Tue, 12 Jun 2018 15:33:49 +0200 Subject: [PATCH 10/10] Updated samples --- .../petstore/cpp-pistache/.openapi-generator/VERSION | 2 +- .../server/petstore/cpp-pistache/model/ModelBase.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION index 096bf47efe31..1c00c5181548 100644 --- a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION +++ b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/cpp-pistache/model/ModelBase.h b/samples/server/petstore/cpp-pistache/model/ModelBase.h index 1b5495b28009..6b5589472f0e 100644 --- a/samples/server/petstore/cpp-pistache/model/ModelBase.h +++ b/samples/server/petstore/cpp-pistache/model/ModelBase.h @@ -39,12 +39,12 @@ class ModelBase virtual nlohmann::json toJson() const = 0; virtual void fromJson(nlohmann::json& json) = 0; - static std::string toJson( std::string const& value ) const; - static std::string toJson( std::time_t const& value ) const; - static int32_t toJson( int32_t const value ) const; - static int64_t toJson( int64_t const value ) const; - static double toJson( double const value ) const; - static bool toJson( bool const value ) const; + static std::string toJson( std::string const& value ); + static std::string toJson( std::time_t const& value ); + static int32_t toJson( int32_t const value ); + static int64_t toJson( int64_t const value ); + static double toJson( double const value ); + static bool toJson( bool const value ); static nlohmann::json toJson(ModelBase const& content ); };