diff --git a/bin/configs/other/cpp-qt5-client.yaml b/bin/configs/cpp-qt5-client.yaml similarity index 100% rename from bin/configs/other/cpp-qt5-client.yaml rename to bin/configs/cpp-qt5-client.yaml diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java index 314fde7a787..fb99201f1f9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java @@ -369,7 +369,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg } CodegenServerList.add(s); } - this.vendorExtensions.put("x-codegen-globalServerList", CodegenServerList); + this.vendorExtensions.put("x-cpp-global-server-list", CodegenServerList); } } diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache index db31fb6a92e..9dbb60f4eeb 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache @@ -30,8 +30,7 @@ void {{classname}}::initializeServerConfigs(){ QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>(); //varying endpoint server QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>(); -{{#vendorExtensions}} -{{#x-codegen-globalServerList}} +{{#vendorExtensions.x-cpp-global-server-list}} defaultConf.append({{prefix}}ServerConfiguration( "{{{url}}}", "{{{description}}}{{^description}}No description provided{{/description}}", @@ -39,8 +38,7 @@ defaultConf.append({{prefix}}ServerConfiguration( {"{{{name}}}", {{prefix}}ServerVariable("{{{description}}}{{^description}}No description provided{{/description}}","{{{defaultValue}}}", QSet{ {{#enumValues}}{"{{{.}}}"}{{#-last}} })},{{/-last}}{{^-last}},{{/-last}}{{/enumValues}}{{^enumValues}}{"{{defaultValue}}"} })},{{/enumValues}}{{#-last}} }));{{/-last}} {{/variables}}{{^variables}}QMap()));{{/variables}} -{{/x-codegen-globalServerList}} -{{/vendorExtensions}} +{{/vendorExtensions.x-cpp-global-server-list}} {{#operations}} {{#operation}} {{^servers}} diff --git a/samples/client/petstore/cpp-qt5/client/ServerConfiguration.h b/samples/client/petstore/cpp-qt5/client/ServerConfiguration.h deleted file mode 100644 index 339bcd63660..00000000000 --- a/samples/client/petstore/cpp-qt5/client/ServerConfiguration.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * 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. - */ - -/** - * Representing a Server configuration. - */ -#ifndef SERVERVCONFIGURATION_H -#define SERVERVCONFIGURATION_H -#include -#include -#include -#include -#include "ServerVariable.h" - -class ServerConfiguration { -public: - /** - * @param URL A URL to the target host. - * @param description A description of the host designated by the URL. - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ - ServerConfiguration(const QString& URL, const QString& description, const QMap& variables) - : _description(description), - _variables(variables), - _URL(URL){} - ServerConfiguration(){} - ~ServerConfiguration(){} - - /** - * Format URL template using given variables. - * - * @param variables A map between a variable name and its value. - * @return Formatted URL. - */ - QString URL() { - QString url = _URL; - if(!_variables.empty()){ - // go through variables and replace placeholders - for (auto const& v : _variables.keys()) { - QString name = v; - ServerVariable serverVariable = _variables.value(v); - QString value = serverVariable._defaultValue; - - if (!serverVariable._enumValues.empty() && !serverVariable._enumValues.contains(value)) { - throw std::runtime_error(QString("The variable " + name + " in the server URL has invalid value " + value + ".").toUtf8()); - } - QRegularExpression regex(QString("\\{" + name + "\\}")); - url = url.replace(regex, value); - - } - return url; - } - return url; - } - - int setDefaultValue(const QString& variable,const QString& value){ - if(_variables.contains(variable)) - return _variables[variable].setDefaultValue(value); - return -1; - } - - QString _description; - QMap _variables; - QString _URL; - -}; -#endif diff --git a/samples/client/petstore/cpp-qt5/client/ServerVariable.h b/samples/client/petstore/cpp-qt5/client/ServerVariable.h deleted file mode 100644 index 7ba32f75c09..00000000000 --- a/samples/client/petstore/cpp-qt5/client/ServerVariable.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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. - */ - -#ifndef SERVERVARIABLE_H -#define SERVERVARIABLE_H -#include -#include -#include -/** - * Representing a Server Variable for server URL template substitution. - */ -class ServerVariable { -public: - - /** - * @param description A description for the server variable. - * @param defaultValue The default value to use for substitution. - * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. - */ - ServerVariable(const QString &description, const QString &defaultValue, const QSet &enumValues) - : _defaultValue(defaultValue), - _description(description), - _enumValues(enumValues){} - - ServerVariable(){} - ~ServerVariable(){} - - int setDefaultValue(const QString& value){ - if( _enumValues.contains(value)){ - _defaultValue = value; - return 0; - } - return -2; - } - - QString getDefaultValue(){return _defaultValue;} - QSet getEnumValues(){return _enumValues;} - - - QString _defaultValue; - QString _description; - QSet _enumValues; - -}; -#endif \ No newline at end of file