diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java index 8277a10ae17ab..0adc037028bae 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java @@ -111,8 +111,8 @@ public interface IJsonSchemaValidationProperties { * - categoryOneOf is a parameter of class GetAccountVideos_categoryOneOf_parameter, a model parameter that correctly prefixed by its namespace: org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter
* - but that GetAccountVideos_categoryOneOf_parameter class is inside an std::optional
*
- * Then a correct generation of that parameter can be (for C++) const org::openapitools::server::model::std::optional &categoryOneOf
- * but using #isModel alone without #isOptional in mustache might produce const org::openapitools::server::model::std::optional &categoryOneOf instead, that do not compile. + * Then a correct generation of that parameter can be (for C++) const std::optional &categoryOneOf
+ * but using #isModel alone without #isOptional in mustache might produce const org::openapitools::server::model::std::optional &categoryOneOf instead, that do not compile. */ boolean getIsOptional(); void setIsOptional(boolean isOptional); 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 b8c4e8b27475a..2e6f70491ec72 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 @@ -65,7 +65,7 @@ private: {{#allParams}} /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} {{/allParams}} - virtual void {{operationIdSnakeCase}}({{#allParams}}const {{#isModel}}{{modelNamespace}}::{{/isModel}}{{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; + virtual void {{operationIdSnakeCase}}({{#allParams}}const {{#isModel}}{{^isOptional}}{{modelNamespace}}::{{/isOptional}}{{/isModel}}{{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; {{/vendorExtensions.x-codegen-pistache-is-parsing-supported}} {{^vendorExtensions.x-codegen-pistache-is-parsing-supported}} 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/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache index f6bc8972e9a3f..5b791c498590d 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 @@ -79,6 +79,23 @@ public: friend {{declspec}} void from_json(const nlohmann::json& j, {{classname}}& o);{{#vendorExtensions.x-is-string-enum-container}}{{#anyOf}}{{#-first}} friend {{declspec}} void to_json(nlohmann::json& j, const {{{this}}}& o); friend {{declspec}} void from_json(const nlohmann::json& j, {{{this}}}& o);{{/-first}}{{/anyOf}}{{/vendorExtensions.x-is-string-enum-container}} + + {{#isEnum}} + /// + /// From enumerated value e{{classname}} to string value + /// + static std::string toStringValue(const {{classname}}::e{{classname}} &value) const; + static std::string toStringValue(const {{classname}} &value) const; + {{/isEnum}} + + {{#isEnum}} + /// + /// From string value to enumerated value e{{classname}} + /// + static bool fromStringValue(const std::string &inStr, {{classname}}::e{{classname}} &value); + static bool fromStringValue(const std::string &inStr, {{classname}} &value); + {{/isEnum}} + protected: {{#vars}} {{{dataType}}} m_{{name}}; 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 ae6f06a4cf435..3e5e4fbfbacd2 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 @@ -181,6 +181,41 @@ void {{classname}}::setEnumValue({{{this}}}::e{{{this}}} value) m_value.setValue(value); }{{/-first}}{{/anyOf}}{{/vendorExtensions.x-is-string-enum-container}} +{{#isEnum}} +/// +/// From enumerated value eVideoPrivacySet to string value +/// +std::string {{classname}}::toStringValue(const {{classname}}::e{{classname}} &value) +{ + return "ukn"; +} + +std::string {{classname}}::toStringValue(const {{classname}} &value) +{ + return "ukn"; +} + +/// +/// From string value to enumerated value e{{classname}} +/// +bool {{classname}}::fromStringValue(const std::string &inStr, {{classname}}::e{{classname}} &value) +{ + // TODO get value + {{classname}}::e{{classname}} dummy; + return true; + // TODO throw if invalid value +} + +bool {{classname}}::fromStringValue(const std::string &inStr, {{classname}} &value) +{ + // TODO get value + {{classname}}::e{{classname}} dummy; + return true; + // TODO throw if invalid value +} + +{{/isEnum}} + } // namespace {{modelNamespace}} {{/model}}