From 1eca97f738a1e1c5388e311611b09bb9f3cc25b3 Mon Sep 17 00:00:00 2001 From: Matthias Preu <5973515+mpreu@users.noreply.github.com> Date: Mon, 3 Jun 2019 09:41:45 +0200 Subject: [PATCH] Fix wrong include path in api-header template (#3062) Change local json.hpp include path to correct value. Update samples. --- .../cpp-pistache-server/api-header.mustache | 2 +- .../cpp-pistache/.openapi-generator/VERSION | 2 +- .../cpp-pistache/model/Inline_object.cpp | 101 ++++++++++++++++++ .../cpp-pistache/model/Inline_object.h | 73 +++++++++++++ .../cpp-pistache/model/Inline_object_1.cpp | 100 +++++++++++++++++ .../cpp-pistache/model/Inline_object_1.h | 73 +++++++++++++ 6 files changed, 349 insertions(+), 2 deletions(-) create mode 100644 samples/server/petstore/cpp-pistache/model/Inline_object.cpp create mode 100644 samples/server/petstore/cpp-pistache/model/Inline_object.h create mode 100644 samples/server/petstore/cpp-pistache/model/Inline_object_1.cpp create mode 100644 samples/server/petstore/cpp-pistache/model/Inline_object_1.h 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 85b84385b73..b8858070611 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 @@ -13,7 +13,7 @@ #include #include #include -{{^hasModelImport}}#include "json.hpp"{{/hasModelImport}} +{{^hasModelImport}}#include {{/hasModelImport}} {{#imports}}{{{import}}} {{/imports}} diff --git a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION index 06b5019af3f..d96260ba335 100644 --- a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION +++ b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.1-SNAPSHOT \ No newline at end of file +4.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/cpp-pistache/model/Inline_object.cpp b/samples/server/petstore/cpp-pistache/model/Inline_object.cpp new file mode 100644 index 00000000000..ebb31303908 --- /dev/null +++ b/samples/server/petstore/cpp-pistache/model/Inline_object.cpp @@ -0,0 +1,101 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ + + +#include "Inline_object.h" + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +Inline_object::Inline_object() +{ + m_Name = ""; + m_NameIsSet = false; + m_Status = ""; + m_StatusIsSet = false; + +} + +Inline_object::~Inline_object() +{ +} + +void Inline_object::validate() +{ + // TODO: implement validation +} + +void to_json(nlohmann::json& j, const Inline_object& o) +{ + j = nlohmann::json(); + if(o.nameIsSet()) + j["name"] = o.m_Name; + if(o.statusIsSet()) + j["status"] = o.m_Status; +} + +void from_json(const nlohmann::json& j, Inline_object& o) +{ + if(j.contains("name")) + { + j.at("name").get_to(o.m_Name); + o.m_NameIsSet = true; + } + if(j.contains("status")) + { + j.at("status").get_to(o.m_Status); + o.m_StatusIsSet = true; + } +} + +std::string Inline_object::getName() const +{ + return m_Name; +} +void Inline_object::setName(std::string const& value) +{ + m_Name = value; + m_NameIsSet = true; +} +bool Inline_object::nameIsSet() const +{ + return m_NameIsSet; +} +void Inline_object::unsetName() +{ + m_NameIsSet = false; +} +std::string Inline_object::getStatus() const +{ + return m_Status; +} +void Inline_object::setStatus(std::string const& value) +{ + m_Status = value; + m_StatusIsSet = true; +} +bool Inline_object::statusIsSet() const +{ + return m_StatusIsSet; +} +void Inline_object::unsetStatus() +{ + m_StatusIsSet = false; +} + +} +} +} +} + diff --git a/samples/server/petstore/cpp-pistache/model/Inline_object.h b/samples/server/petstore/cpp-pistache/model/Inline_object.h new file mode 100644 index 00000000000..f407884cd88 --- /dev/null +++ b/samples/server/petstore/cpp-pistache/model/Inline_object.h @@ -0,0 +1,73 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +/* + * Inline_object.h + * + * + */ + +#ifndef Inline_object_H_ +#define Inline_object_H_ + + +#include +#include + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +/// +/// +/// +class Inline_object +{ +public: + Inline_object(); + virtual ~Inline_object(); + + void validate(); + + ///////////////////////////////////////////// + /// Inline_object members + + /// + /// Updated name of the pet + /// + std::string getName() const; + void setName(std::string const& value); + bool nameIsSet() const; + void unsetName(); + /// + /// Updated status of the pet + /// + std::string getStatus() const; + void setStatus(std::string const& value); + bool statusIsSet() const; + void unsetStatus(); + + friend void to_json(nlohmann::json& j, const Inline_object& o); + friend void from_json(const nlohmann::json& j, Inline_object& o); +protected: + std::string m_Name; + bool m_NameIsSet; + std::string m_Status; + bool m_StatusIsSet; +}; + +} +} +} +} + +#endif /* Inline_object_H_ */ diff --git a/samples/server/petstore/cpp-pistache/model/Inline_object_1.cpp b/samples/server/petstore/cpp-pistache/model/Inline_object_1.cpp new file mode 100644 index 00000000000..d5ffe1fef88 --- /dev/null +++ b/samples/server/petstore/cpp-pistache/model/Inline_object_1.cpp @@ -0,0 +1,100 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ + + +#include "Inline_object_1.h" + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +Inline_object_1::Inline_object_1() +{ + m_AdditionalMetadata = ""; + m_AdditionalMetadataIsSet = false; + m_fileIsSet = false; + +} + +Inline_object_1::~Inline_object_1() +{ +} + +void Inline_object_1::validate() +{ + // TODO: implement validation +} + +void to_json(nlohmann::json& j, const Inline_object_1& o) +{ + j = nlohmann::json(); + if(o.additionalMetadataIsSet()) + j["additionalMetadata"] = o.m_AdditionalMetadata; + if(o.fileIsSet()) + j["file"] = o.m_file; +} + +void from_json(const nlohmann::json& j, Inline_object_1& o) +{ + if(j.contains("additionalMetadata")) + { + j.at("additionalMetadata").get_to(o.m_AdditionalMetadata); + o.m_AdditionalMetadataIsSet = true; + } + if(j.contains("file")) + { + j.at("file").get_to(o.m_file); + o.m_fileIsSet = true; + } +} + +std::string Inline_object_1::getAdditionalMetadata() const +{ + return m_AdditionalMetadata; +} +void Inline_object_1::setAdditionalMetadata(std::string const& value) +{ + m_AdditionalMetadata = value; + m_AdditionalMetadataIsSet = true; +} +bool Inline_object_1::additionalMetadataIsSet() const +{ + return m_AdditionalMetadataIsSet; +} +void Inline_object_1::unsetAdditionalMetadata() +{ + m_AdditionalMetadataIsSet = false; +} +std::string Inline_object_1::getFile() const +{ + return m_file; +} +void Inline_object_1::setFile(std::string const& value) +{ + m_file = value; + m_fileIsSet = true; +} +bool Inline_object_1::fileIsSet() const +{ + return m_fileIsSet; +} +void Inline_object_1::unsetfile() +{ + m_fileIsSet = false; +} + +} +} +} +} + diff --git a/samples/server/petstore/cpp-pistache/model/Inline_object_1.h b/samples/server/petstore/cpp-pistache/model/Inline_object_1.h new file mode 100644 index 00000000000..a5d90b1754e --- /dev/null +++ b/samples/server/petstore/cpp-pistache/model/Inline_object_1.h @@ -0,0 +1,73 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +/* + * Inline_object_1.h + * + * + */ + +#ifndef Inline_object_1_H_ +#define Inline_object_1_H_ + + +#include +#include + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +/// +/// +/// +class Inline_object_1 +{ +public: + Inline_object_1(); + virtual ~Inline_object_1(); + + void validate(); + + ///////////////////////////////////////////// + /// Inline_object_1 members + + /// + /// Additional data to pass to server + /// + std::string getAdditionalMetadata() const; + void setAdditionalMetadata(std::string const& value); + bool additionalMetadataIsSet() const; + void unsetAdditionalMetadata(); + /// + /// file to upload + /// + std::string getFile() const; + void setFile(std::string const& value); + bool fileIsSet() const; + void unsetfile(); + + friend void to_json(nlohmann::json& j, const Inline_object_1& o); + friend void from_json(const nlohmann::json& j, Inline_object_1& o); +protected: + std::string m_AdditionalMetadata; + bool m_AdditionalMetadataIsSet; + std::string m_file; + bool m_fileIsSet; +}; + +} +} +} +} + +#endif /* Inline_object_1_H_ */