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 855560a0b0d768f190f10a3b56b2ac0ce4aac9f1..fa562529c55972845c916000e927dbcce83b8176 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 @@ -14,20 +14,20 @@ namespace {{this}} { _manager(nullptr), isResponseCompressionEnabled(false), isRequestCompressionEnabled(false) { - initializeServerConfigs(); - } + initializeServerConfigs(); +} {{classname}}::~{{classname}}() { } void {{classname}}::initializeServerConfigs(){ -//Default server -QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>(); -//varying endpoint server -QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>(); + //Default server + QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>(); + //varying endpoint server + QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>(); {{#vendorExtensions.x-cpp-global-server-list}} -defaultConf.append({{prefix}}ServerConfiguration( + defaultConf.append({{prefix}}ServerConfiguration( QUrl("{{{url}}}"), "{{{description}}}{{^description}}No description provided{{/description}}", {{#variables}}{{#-first}}QMap<QString, {{prefix}}ServerVariable>{ {{/-first}} @@ -36,32 +36,29 @@ defaultConf.append({{prefix}}ServerConfiguration( {{/variables}}{{^variables}}QMap<QString, {{prefix}}ServerVariable>()));{{/variables}} {{/vendorExtensions.x-cpp-global-server-list}} {{#operations}} - {{#operation}} - {{^servers}} -_serverConfigs.insert("{{nickname}}",defaultConf); -_serverIndices.insert("{{nickname}}",0); - -{{/servers}} -{{#servers}} -serverConf.append({{prefix}}ServerConfiguration( + {{#operation}} + {{^servers}} + _serverConfigs.insert("{{nickname}}",defaultConf); + _serverIndices.insert("{{nickname}}",0); + {{/servers}} + {{#servers}} + serverConf.append({{prefix}}ServerConfiguration( QUrl("{{{url}}}"), "{{{description}}}{{^description}}No description provided{{/description}}", {{#variables}}{{#-first}}QMap<QString, {{prefix}}ServerVariable>{ {{/-first}} {"{{{name}}}", {{prefix}}ServerVariable("{{{description}}}{{^description}}No description provided{{/description}}","{{{defaultValue}}}", QSet<QString>{ {{#enumValues}}{"{{{.}}}"}{{#-last}} })}, {{/-last}}{{^-last}},{{/-last}}{{/enumValues}}{{^enumValues}}{"{{defaultValue}}"} })},{{/enumValues}}{{#-last}} }));{{/-last}} {{/variables}}{{^variables}}QMap<QString, {{prefix}}ServerVariable>()));{{/variables}} -{{#-last}}_serverConfigs.insert("{{nickname}}",serverConf); -_serverIndices.insert("{{nickname}}",0);{{/-last}} - + {{#-last}}_serverConfigs.insert("{{nickname}}",serverConf); + _serverIndices.insert("{{nickname}}",0);{{/-last}} {{/servers}} {{/operation}} {{/operations}} - } /** * returns 0 on success and -1, -2 or -3 on failure. -* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found +* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found */ int {{classname}}::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){ auto it = _serverConfigs.find(operation); @@ -101,17 +98,17 @@ void {{classname}}::setWorkingDirectory(const QString &path) { } void {{classname}}::setNetworkAccessManager(QNetworkAccessManager* manager) { - _manager = manager; + _manager = manager; } - /** - * Appends a new ServerConfiguration to the config map for a specific operation. - * @param operation The id to the target operation. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - * returns the index of the new server config on success and -1 if the operation is not found - */ +/** + * Appends a new ServerConfiguration to the config map for a specific operation. + * @param operation The id to the target operation. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + * returns the index of the new server config on success and -1 if the operation is not found + */ int {{classname}}::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables){ if(_serverConfigs.contains(operation)){ _serverConfigs[operation].append({{prefix}}ServerConfiguration( @@ -124,27 +121,26 @@ int {{classname}}::addServerConfiguration(const QString &operation, const QUrl & } } - /** - * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ +/** + * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ void {{classname}}::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables){ - for(auto e : _serverIndices.keys()){ - setServerIndex(e, addServerConfiguration(e, url, description, variables)); - } -} - /** - * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. - * @param URL A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ -void {{classname}}::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables){ + for(auto e : _serverIndices.keys()){ + setServerIndex(e, addServerConfiguration(e, url, description, variables)); + } +} +/** + * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. + * @param URL A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ +void {{classname}}::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables){ setServerIndex(operation, addServerConfiguration(operation, url, description, variables)); - } void {{classname}}::addHeaders(const QString &key, const QString &value) { @@ -164,65 +160,66 @@ void {{classname}}::abortRequests(){ } QString {{classname}}::getParamStylePrefix(QString style){ - - if(style == "matrix"){ - return ";"; - }else if(style == "label"){ - return "."; - }else if(style == "form"){ - return "&"; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "&"; - }else if(style == "pipeDelimited"){ - return "&"; - }else - return "none"; + if(style == "matrix"){ + return ";"; + }else if(style == "label"){ + return "."; + }else if(style == "form"){ + return "&"; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "&"; + }else if(style == "pipeDelimited"){ + return "&"; + }else{ + return "none"; + } } QString {{classname}}::getParamStyleSuffix(QString style){ - - if(style == "matrix"){ - return "="; - }else if(style == "label"){ - return ""; - }else if(style == "form"){ - return "="; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "="; - }else if(style == "pipeDelimited"){ - return "="; - }else - return "none"; + if(style == "matrix"){ + return "="; + }else if(style == "label"){ + return ""; + }else if(style == "form"){ + return "="; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "="; + }else if(style == "pipeDelimited"){ + return "="; + }else{ + return "none"; + } } QString {{classname}}::getParamStyleDelimiter(QString style, QString name, bool isExplode){ - if(style == "matrix"){ - return (isExplode) ? ";" + name + "=" : ","; + if(style == "matrix"){ + return (isExplode) ? ";" + name + "=" : ","; - }else if(style == "label"){ - return (isExplode) ? "." : ","; + }else if(style == "label"){ + return (isExplode) ? "." : ","; - }else if(style == "form"){ - return (isExplode) ? "&" + name + "=" : ","; + }else if(style == "form"){ + return (isExplode) ? "&" + name + "=" : ","; - }else if(style == "simple"){ - return ","; - }else if(style == "spaceDelimited"){ - return (isExplode) ? "&" + name + "=" : " "; + }else if(style == "simple"){ + return ","; + }else if(style == "spaceDelimited"){ + return (isExplode) ? "&" + name + "=" : " "; - }else if(style == "pipeDelimited"){ - return (isExplode) ? "&" + name + "=" : "|"; + }else if(style == "pipeDelimited"){ + return (isExplode) ? "&" + name + "=" : "|"; - }else if(style == "deepObject"){ - return (isExplode) ? "&" : "none"; + }else if(style == "deepObject"){ + return (isExplode) ? "&" : "none"; - }else - return "none"; + }else { + return "none"; + } } {{#operations}} @@ -257,8 +254,8 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} QString {{paramName}}PathParam("{"); {{paramName}}PathParam.append("{{baseName}}").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = "{{style}}"; - if(pathStyle == "") + QString pathStyle = "{{style}}"; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -337,11 +334,11 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} {{^required}}if(!{{paramName}}.isNull()){{/required}} { queryStyle = "{{style}}"; - if(queryStyle == "") + if(queryStyle == "") queryStyle = "form"; queryPrefix = getParamStylePrefix(queryStyle); querySuffix = getParamStyleSuffix(queryStyle); - queryDelimiter = getParamStyleDelimiter(queryStyle, "{{baseName}}", {{isExplode}}); + queryDelimiter = getParamStyleDelimiter(queryStyle, "{{baseName}}", {{isExplode}}); {{^collectionFormat}} if (fullPath.indexOf("?") > 0) fullPath.append(queryPrefix); @@ -472,7 +469,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} } fullPath.append(::{{cppNamespace}}::toStringValue(t)); count++; - } + } } } {{/collectionFormat}} @@ -490,7 +487,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} {{#first}} QString formPrefix,formSuffix, formDelimiter; QString formStyle = "{{style}}"; - if(formStyle == "") + if(formStyle == "") formStyle = "form"; formPrefix = getParamStylePrefix(formStyle); formSuffix = getParamStyleSuffix(formStyle); @@ -665,7 +662,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &{{prefix}}HttpRequestWorker::on_execution_finished, this, &{{classname}}::{{nickname}}Callback); - connect(this, &{{classname}}::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &{{classname}}::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } diff --git a/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp index 79cad8362a57d9a18422258cb54683830d12a97b..2c2ed764180ef683bd8b730adf016666763ae32d 100644 --- a/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp @@ -22,52 +22,43 @@ PFXPetApi::PFXPetApi(const int timeOut) _manager(nullptr), isResponseCompressionEnabled(false), isRequestCompressionEnabled(false) { - initializeServerConfigs(); - } + initializeServerConfigs(); +} PFXPetApi::~PFXPetApi() { } void PFXPetApi::initializeServerConfigs(){ -//Default server -QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>(); -//varying endpoint server -QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>(); -defaultConf.append(PFXServerConfiguration( + //Default server + QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>(); + //varying endpoint server + QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>(); + defaultConf.append(PFXServerConfiguration( QUrl("http://petstore.swagger.io/v2"), "No description provided", QMap<QString, PFXServerVariable>())); -_serverConfigs.insert("addPet",defaultConf); -_serverIndices.insert("addPet",0); - -_serverConfigs.insert("deletePet",defaultConf); -_serverIndices.insert("deletePet",0); - -_serverConfigs.insert("findPetsByStatus",defaultConf); -_serverIndices.insert("findPetsByStatus",0); - -_serverConfigs.insert("findPetsByTags",defaultConf); -_serverIndices.insert("findPetsByTags",0); - -_serverConfigs.insert("getPetById",defaultConf); -_serverIndices.insert("getPetById",0); - -_serverConfigs.insert("updatePet",defaultConf); -_serverIndices.insert("updatePet",0); - -_serverConfigs.insert("updatePetWithForm",defaultConf); -_serverIndices.insert("updatePetWithForm",0); - -_serverConfigs.insert("uploadFile",defaultConf); -_serverIndices.insert("uploadFile",0); - - + _serverConfigs.insert("addPet",defaultConf); + _serverIndices.insert("addPet",0); + _serverConfigs.insert("deletePet",defaultConf); + _serverIndices.insert("deletePet",0); + _serverConfigs.insert("findPetsByStatus",defaultConf); + _serverIndices.insert("findPetsByStatus",0); + _serverConfigs.insert("findPetsByTags",defaultConf); + _serverIndices.insert("findPetsByTags",0); + _serverConfigs.insert("getPetById",defaultConf); + _serverIndices.insert("getPetById",0); + _serverConfigs.insert("updatePet",defaultConf); + _serverIndices.insert("updatePet",0); + _serverConfigs.insert("updatePetWithForm",defaultConf); + _serverIndices.insert("updatePetWithForm",0); + _serverConfigs.insert("uploadFile",defaultConf); + _serverIndices.insert("uploadFile",0); } /** * returns 0 on success and -1, -2 or -3 on failure. -* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found +* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found */ int PFXPetApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){ auto it = _serverConfigs.find(operation); @@ -107,17 +98,17 @@ void PFXPetApi::setWorkingDirectory(const QString &path) { } void PFXPetApi::setNetworkAccessManager(QNetworkAccessManager* manager) { - _manager = manager; + _manager = manager; } - /** - * Appends a new ServerConfiguration to the config map for a specific operation. - * @param operation The id to the target operation. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - * returns the index of the new server config on success and -1 if the operation is not found - */ +/** + * Appends a new ServerConfiguration to the config map for a specific operation. + * @param operation The id to the target operation. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + * returns the index of the new server config on success and -1 if the operation is not found + */ int PFXPetApi::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ if(_serverConfigs.contains(operation)){ _serverConfigs[operation].append(PFXServerConfiguration( @@ -130,27 +121,26 @@ int PFXPetApi::addServerConfiguration(const QString &operation, const QUrl &url, } } - /** - * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ +/** + * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ void PFXPetApi::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ - for(auto e : _serverIndices.keys()){ - setServerIndex(e, addServerConfiguration(e, url, description, variables)); - } -} - /** - * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. - * @param URL A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ -void PFXPetApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ + for(auto e : _serverIndices.keys()){ + setServerIndex(e, addServerConfiguration(e, url, description, variables)); + } +} +/** + * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. + * @param URL A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ +void PFXPetApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ setServerIndex(operation, addServerConfiguration(operation, url, description, variables)); - } void PFXPetApi::addHeaders(const QString &key, const QString &value) { @@ -170,65 +160,66 @@ void PFXPetApi::abortRequests(){ } QString PFXPetApi::getParamStylePrefix(QString style){ - - if(style == "matrix"){ - return ";"; - }else if(style == "label"){ - return "."; - }else if(style == "form"){ - return "&"; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "&"; - }else if(style == "pipeDelimited"){ - return "&"; - }else - return "none"; + if(style == "matrix"){ + return ";"; + }else if(style == "label"){ + return "."; + }else if(style == "form"){ + return "&"; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "&"; + }else if(style == "pipeDelimited"){ + return "&"; + }else{ + return "none"; + } } QString PFXPetApi::getParamStyleSuffix(QString style){ - - if(style == "matrix"){ - return "="; - }else if(style == "label"){ - return ""; - }else if(style == "form"){ - return "="; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "="; - }else if(style == "pipeDelimited"){ - return "="; - }else - return "none"; + if(style == "matrix"){ + return "="; + }else if(style == "label"){ + return ""; + }else if(style == "form"){ + return "="; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "="; + }else if(style == "pipeDelimited"){ + return "="; + }else{ + return "none"; + } } QString PFXPetApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){ - if(style == "matrix"){ - return (isExplode) ? ";" + name + "=" : ","; + if(style == "matrix"){ + return (isExplode) ? ";" + name + "=" : ","; - }else if(style == "label"){ - return (isExplode) ? "." : ","; + }else if(style == "label"){ + return (isExplode) ? "." : ","; - }else if(style == "form"){ - return (isExplode) ? "&" + name + "=" : ","; + }else if(style == "form"){ + return (isExplode) ? "&" + name + "=" : ","; - }else if(style == "simple"){ - return ","; - }else if(style == "spaceDelimited"){ - return (isExplode) ? "&" + name + "=" : " "; + }else if(style == "simple"){ + return ","; + }else if(style == "spaceDelimited"){ + return (isExplode) ? "&" + name + "=" : " "; - }else if(style == "pipeDelimited"){ - return (isExplode) ? "&" + name + "=" : "|"; + }else if(style == "pipeDelimited"){ + return (isExplode) ? "&" + name + "=" : "|"; - }else if(style == "deepObject"){ - return (isExplode) ? "&" : "none"; + }else if(style == "deepObject"){ + return (isExplode) ? "&" : "none"; - }else - return "none"; + }else { + return "none"; + } } void PFXPetApi::addPet(const PFXPet &body) { @@ -246,7 +237,7 @@ void PFXPetApi::addPet(const PFXPet &body) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -281,8 +272,8 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const QVariant &api_key) { QString pet_idPathParam("{"); pet_idPathParam.append("petId").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -305,7 +296,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const QVariant &api_key) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::deletePetCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -339,11 +330,11 @@ void PFXPetApi::findPetsByStatus(const QList<QString> &status) { { queryStyle = "form"; - if(queryStyle == "") + if(queryStyle == "") queryStyle = "form"; queryPrefix = getParamStylePrefix(queryStyle); querySuffix = getParamStyleSuffix(queryStyle); - queryDelimiter = getParamStyleDelimiter(queryStyle, "status", false); + queryDelimiter = getParamStyleDelimiter(queryStyle, "status", false); if (status.size() > 0) { if (QString("csv").indexOf("multi") == 0) { foreach (QString t, status) { @@ -417,7 +408,7 @@ void PFXPetApi::findPetsByStatus(const QList<QString> &status) { } fullPath.append(::test_namespace::toStringValue(t)); count++; - } + } } } } @@ -430,7 +421,7 @@ void PFXPetApi::findPetsByStatus(const QList<QString> &status) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByStatusCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -474,11 +465,11 @@ void PFXPetApi::findPetsByTags(const QList<QString> &tags) { { queryStyle = "form"; - if(queryStyle == "") + if(queryStyle == "") queryStyle = "form"; queryPrefix = getParamStylePrefix(queryStyle); querySuffix = getParamStyleSuffix(queryStyle); - queryDelimiter = getParamStyleDelimiter(queryStyle, "tags", false); + queryDelimiter = getParamStyleDelimiter(queryStyle, "tags", false); if (tags.size() > 0) { if (QString("csv").indexOf("multi") == 0) { foreach (QString t, tags) { @@ -552,7 +543,7 @@ void PFXPetApi::findPetsByTags(const QList<QString> &tags) { } fullPath.append(::test_namespace::toStringValue(t)); count++; - } + } } } } @@ -565,7 +556,7 @@ void PFXPetApi::findPetsByTags(const QList<QString> &tags) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByTagsCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -614,8 +605,8 @@ void PFXPetApi::getPetById(const qint64 &pet_id) { QString pet_idPathParam("{"); pet_idPathParam.append("petId").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -632,7 +623,7 @@ void PFXPetApi::getPetById(const qint64 &pet_id) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::getPetByIdCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -674,7 +665,7 @@ void PFXPetApi::updatePet(const PFXPet &body) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -709,8 +700,8 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QVariant &name, co QString pet_idPathParam("{"); pet_idPathParam.append("petId").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -739,7 +730,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QVariant &name, co foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetWithFormCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -774,8 +765,8 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const QVariant &additional_meta QString pet_idPathParam("{"); pet_idPathParam.append("petId").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -804,7 +795,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const QVariant &additional_meta foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::uploadFileCallback); - connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } diff --git a/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp b/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp index e8e8c4a94c2ff7321a85a1f792106d4cd75c1521..d239c81c7ac1ddbf56bea0b7fd14f4f419f9677a 100644 --- a/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp +++ b/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp @@ -22,40 +22,35 @@ PFXStoreApi::PFXStoreApi(const int timeOut) _manager(nullptr), isResponseCompressionEnabled(false), isRequestCompressionEnabled(false) { - initializeServerConfigs(); - } + initializeServerConfigs(); +} PFXStoreApi::~PFXStoreApi() { } void PFXStoreApi::initializeServerConfigs(){ -//Default server -QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>(); -//varying endpoint server -QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>(); -defaultConf.append(PFXServerConfiguration( + //Default server + QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>(); + //varying endpoint server + QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>(); + defaultConf.append(PFXServerConfiguration( QUrl("http://petstore.swagger.io/v2"), "No description provided", QMap<QString, PFXServerVariable>())); -_serverConfigs.insert("deleteOrder",defaultConf); -_serverIndices.insert("deleteOrder",0); - -_serverConfigs.insert("getInventory",defaultConf); -_serverIndices.insert("getInventory",0); - -_serverConfigs.insert("getOrderById",defaultConf); -_serverIndices.insert("getOrderById",0); - -_serverConfigs.insert("placeOrder",defaultConf); -_serverIndices.insert("placeOrder",0); - - + _serverConfigs.insert("deleteOrder",defaultConf); + _serverIndices.insert("deleteOrder",0); + _serverConfigs.insert("getInventory",defaultConf); + _serverIndices.insert("getInventory",0); + _serverConfigs.insert("getOrderById",defaultConf); + _serverIndices.insert("getOrderById",0); + _serverConfigs.insert("placeOrder",defaultConf); + _serverIndices.insert("placeOrder",0); } /** * returns 0 on success and -1, -2 or -3 on failure. -* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found +* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found */ int PFXStoreApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){ auto it = _serverConfigs.find(operation); @@ -95,17 +90,17 @@ void PFXStoreApi::setWorkingDirectory(const QString &path) { } void PFXStoreApi::setNetworkAccessManager(QNetworkAccessManager* manager) { - _manager = manager; + _manager = manager; } - /** - * Appends a new ServerConfiguration to the config map for a specific operation. - * @param operation The id to the target operation. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - * returns the index of the new server config on success and -1 if the operation is not found - */ +/** + * Appends a new ServerConfiguration to the config map for a specific operation. + * @param operation The id to the target operation. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + * returns the index of the new server config on success and -1 if the operation is not found + */ int PFXStoreApi::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ if(_serverConfigs.contains(operation)){ _serverConfigs[operation].append(PFXServerConfiguration( @@ -118,27 +113,26 @@ int PFXStoreApi::addServerConfiguration(const QString &operation, const QUrl &ur } } - /** - * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ +/** + * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ void PFXStoreApi::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ - for(auto e : _serverIndices.keys()){ - setServerIndex(e, addServerConfiguration(e, url, description, variables)); - } -} - /** - * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. - * @param URL A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ -void PFXStoreApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ + for(auto e : _serverIndices.keys()){ + setServerIndex(e, addServerConfiguration(e, url, description, variables)); + } +} +/** + * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. + * @param URL A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ +void PFXStoreApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ setServerIndex(operation, addServerConfiguration(operation, url, description, variables)); - } void PFXStoreApi::addHeaders(const QString &key, const QString &value) { @@ -158,65 +152,66 @@ void PFXStoreApi::abortRequests(){ } QString PFXStoreApi::getParamStylePrefix(QString style){ - - if(style == "matrix"){ - return ";"; - }else if(style == "label"){ - return "."; - }else if(style == "form"){ - return "&"; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "&"; - }else if(style == "pipeDelimited"){ - return "&"; - }else - return "none"; + if(style == "matrix"){ + return ";"; + }else if(style == "label"){ + return "."; + }else if(style == "form"){ + return "&"; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "&"; + }else if(style == "pipeDelimited"){ + return "&"; + }else{ + return "none"; + } } QString PFXStoreApi::getParamStyleSuffix(QString style){ - - if(style == "matrix"){ - return "="; - }else if(style == "label"){ - return ""; - }else if(style == "form"){ - return "="; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "="; - }else if(style == "pipeDelimited"){ - return "="; - }else - return "none"; + if(style == "matrix"){ + return "="; + }else if(style == "label"){ + return ""; + }else if(style == "form"){ + return "="; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "="; + }else if(style == "pipeDelimited"){ + return "="; + }else{ + return "none"; + } } QString PFXStoreApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){ - if(style == "matrix"){ - return (isExplode) ? ";" + name + "=" : ","; + if(style == "matrix"){ + return (isExplode) ? ";" + name + "=" : ","; - }else if(style == "label"){ - return (isExplode) ? "." : ","; + }else if(style == "label"){ + return (isExplode) ? "." : ","; - }else if(style == "form"){ - return (isExplode) ? "&" + name + "=" : ","; + }else if(style == "form"){ + return (isExplode) ? "&" + name + "=" : ","; - }else if(style == "simple"){ - return ","; - }else if(style == "spaceDelimited"){ - return (isExplode) ? "&" + name + "=" : " "; + }else if(style == "simple"){ + return ","; + }else if(style == "spaceDelimited"){ + return (isExplode) ? "&" + name + "=" : " "; - }else if(style == "pipeDelimited"){ - return (isExplode) ? "&" + name + "=" : "|"; + }else if(style == "pipeDelimited"){ + return (isExplode) ? "&" + name + "=" : "|"; - }else if(style == "deepObject"){ - return (isExplode) ? "&" : "none"; + }else if(style == "deepObject"){ + return (isExplode) ? "&" : "none"; - }else - return "none"; + }else { + return "none"; + } } void PFXStoreApi::deleteOrder(const QString &order_id) { @@ -228,8 +223,8 @@ void PFXStoreApi::deleteOrder(const QString &order_id) { QString order_idPathParam("{"); order_idPathParam.append("orderId").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -246,7 +241,7 @@ void PFXStoreApi::deleteOrder(const QString &order_id) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::deleteOrderCallback); - connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -288,7 +283,7 @@ void PFXStoreApi::getInventory() { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getInventoryCallback); - connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -333,8 +328,8 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) { QString order_idPathParam("{"); order_idPathParam.append("orderId").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -351,7 +346,7 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getOrderByIdCallback); - connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -393,7 +388,7 @@ void PFXStoreApi::placeOrder(const PFXOrder &body) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::placeOrderCallback); - connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } diff --git a/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp b/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp index 2379544e5213dd935389e4b8644bf6463d4c8b52..3d118c802793953507fe4bb5912796ecbefa46fc 100644 --- a/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp +++ b/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp @@ -22,52 +22,43 @@ PFXUserApi::PFXUserApi(const int timeOut) _manager(nullptr), isResponseCompressionEnabled(false), isRequestCompressionEnabled(false) { - initializeServerConfigs(); - } + initializeServerConfigs(); +} PFXUserApi::~PFXUserApi() { } void PFXUserApi::initializeServerConfigs(){ -//Default server -QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>(); -//varying endpoint server -QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>(); -defaultConf.append(PFXServerConfiguration( + //Default server + QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>(); + //varying endpoint server + QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>(); + defaultConf.append(PFXServerConfiguration( QUrl("http://petstore.swagger.io/v2"), "No description provided", QMap<QString, PFXServerVariable>())); -_serverConfigs.insert("createUser",defaultConf); -_serverIndices.insert("createUser",0); - -_serverConfigs.insert("createUsersWithArrayInput",defaultConf); -_serverIndices.insert("createUsersWithArrayInput",0); - -_serverConfigs.insert("createUsersWithListInput",defaultConf); -_serverIndices.insert("createUsersWithListInput",0); - -_serverConfigs.insert("deleteUser",defaultConf); -_serverIndices.insert("deleteUser",0); - -_serverConfigs.insert("getUserByName",defaultConf); -_serverIndices.insert("getUserByName",0); - -_serverConfigs.insert("loginUser",defaultConf); -_serverIndices.insert("loginUser",0); - -_serverConfigs.insert("logoutUser",defaultConf); -_serverIndices.insert("logoutUser",0); - -_serverConfigs.insert("updateUser",defaultConf); -_serverIndices.insert("updateUser",0); - - + _serverConfigs.insert("createUser",defaultConf); + _serverIndices.insert("createUser",0); + _serverConfigs.insert("createUsersWithArrayInput",defaultConf); + _serverIndices.insert("createUsersWithArrayInput",0); + _serverConfigs.insert("createUsersWithListInput",defaultConf); + _serverIndices.insert("createUsersWithListInput",0); + _serverConfigs.insert("deleteUser",defaultConf); + _serverIndices.insert("deleteUser",0); + _serverConfigs.insert("getUserByName",defaultConf); + _serverIndices.insert("getUserByName",0); + _serverConfigs.insert("loginUser",defaultConf); + _serverIndices.insert("loginUser",0); + _serverConfigs.insert("logoutUser",defaultConf); + _serverIndices.insert("logoutUser",0); + _serverConfigs.insert("updateUser",defaultConf); + _serverIndices.insert("updateUser",0); } /** * returns 0 on success and -1, -2 or -3 on failure. -* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found +* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found */ int PFXUserApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){ auto it = _serverConfigs.find(operation); @@ -107,17 +98,17 @@ void PFXUserApi::setWorkingDirectory(const QString &path) { } void PFXUserApi::setNetworkAccessManager(QNetworkAccessManager* manager) { - _manager = manager; + _manager = manager; } - /** - * Appends a new ServerConfiguration to the config map for a specific operation. - * @param operation The id to the target operation. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - * returns the index of the new server config on success and -1 if the operation is not found - */ +/** + * Appends a new ServerConfiguration to the config map for a specific operation. + * @param operation The id to the target operation. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + * returns the index of the new server config on success and -1 if the operation is not found + */ int PFXUserApi::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ if(_serverConfigs.contains(operation)){ _serverConfigs[operation].append(PFXServerConfiguration( @@ -130,27 +121,26 @@ int PFXUserApi::addServerConfiguration(const QString &operation, const QUrl &url } } - /** - * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. - * @param url A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ +/** + * Appends a new ServerConfiguration to the config map for a all operations and sets the index to that server. + * @param url A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ void PFXUserApi::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ - for(auto e : _serverIndices.keys()){ - setServerIndex(e, addServerConfiguration(e, url, description, variables)); - } -} - /** - * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. - * @param URL A string that contains the URL of the server - * @param description A String that describes the server - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ -void PFXUserApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ + for(auto e : _serverIndices.keys()){ + setServerIndex(e, addServerConfiguration(e, url, description, variables)); + } +} +/** + * Appends a new ServerConfiguration to the config map for an operations and sets the index to that server. + * @param URL A string that contains the URL of the server + * @param description A String that describes the server + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ +void PFXUserApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, PFXServerVariable> &variables){ setServerIndex(operation, addServerConfiguration(operation, url, description, variables)); - } void PFXUserApi::addHeaders(const QString &key, const QString &value) { @@ -170,65 +160,66 @@ void PFXUserApi::abortRequests(){ } QString PFXUserApi::getParamStylePrefix(QString style){ - - if(style == "matrix"){ - return ";"; - }else if(style == "label"){ - return "."; - }else if(style == "form"){ - return "&"; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "&"; - }else if(style == "pipeDelimited"){ - return "&"; - }else - return "none"; + if(style == "matrix"){ + return ";"; + }else if(style == "label"){ + return "."; + }else if(style == "form"){ + return "&"; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "&"; + }else if(style == "pipeDelimited"){ + return "&"; + }else{ + return "none"; + } } QString PFXUserApi::getParamStyleSuffix(QString style){ - - if(style == "matrix"){ - return "="; - }else if(style == "label"){ - return ""; - }else if(style == "form"){ - return "="; - }else if(style == "simple"){ - return ""; - }else if(style == "spaceDelimited"){ - return "="; - }else if(style == "pipeDelimited"){ - return "="; - }else - return "none"; + if(style == "matrix"){ + return "="; + }else if(style == "label"){ + return ""; + }else if(style == "form"){ + return "="; + }else if(style == "simple"){ + return ""; + }else if(style == "spaceDelimited"){ + return "="; + }else if(style == "pipeDelimited"){ + return "="; + }else{ + return "none"; + } } QString PFXUserApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){ - if(style == "matrix"){ - return (isExplode) ? ";" + name + "=" : ","; + if(style == "matrix"){ + return (isExplode) ? ";" + name + "=" : ","; - }else if(style == "label"){ - return (isExplode) ? "." : ","; + }else if(style == "label"){ + return (isExplode) ? "." : ","; - }else if(style == "form"){ - return (isExplode) ? "&" + name + "=" : ","; + }else if(style == "form"){ + return (isExplode) ? "&" + name + "=" : ","; - }else if(style == "simple"){ - return ","; - }else if(style == "spaceDelimited"){ - return (isExplode) ? "&" + name + "=" : " "; + }else if(style == "simple"){ + return ","; + }else if(style == "spaceDelimited"){ + return (isExplode) ? "&" + name + "=" : " "; - }else if(style == "pipeDelimited"){ - return (isExplode) ? "&" + name + "=" : "|"; + }else if(style == "pipeDelimited"){ + return (isExplode) ? "&" + name + "=" : "|"; - }else if(style == "deepObject"){ - return (isExplode) ? "&" : "none"; + }else if(style == "deepObject"){ + return (isExplode) ? "&" : "none"; - }else - return "none"; + }else { + return "none"; + } } void PFXUserApi::createUser(const PFXUser &body) { @@ -246,7 +237,7 @@ void PFXUserApi::createUser(const PFXUser &body) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUserCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -287,7 +278,7 @@ void PFXUserApi::createUsersWithArrayInput(const QList<PFXUser> &body) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithArrayInputCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -328,7 +319,7 @@ void PFXUserApi::createUsersWithListInput(const QList<PFXUser> &body) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithListInputCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -363,8 +354,8 @@ void PFXUserApi::deleteUser(const QString &username) { QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -381,7 +372,7 @@ void PFXUserApi::deleteUser(const QString &username) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::deleteUserCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -416,8 +407,8 @@ void PFXUserApi::getUserByName(const QString &username) { QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -434,7 +425,7 @@ void PFXUserApi::getUserByName(const QString &username) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::getUserByNameCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -469,11 +460,11 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) { { queryStyle = ""; - if(queryStyle == "") + if(queryStyle == "") queryStyle = "form"; queryPrefix = getParamStylePrefix(queryStyle); querySuffix = getParamStyleSuffix(queryStyle); - queryDelimiter = getParamStyleDelimiter(queryStyle, "username", false); + queryDelimiter = getParamStyleDelimiter(queryStyle, "username", false); if (fullPath.indexOf("?") > 0) fullPath.append(queryPrefix); else @@ -485,11 +476,11 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) { { queryStyle = ""; - if(queryStyle == "") + if(queryStyle == "") queryStyle = "form"; queryPrefix = getParamStylePrefix(queryStyle); querySuffix = getParamStyleSuffix(queryStyle); - queryDelimiter = getParamStyleDelimiter(queryStyle, "password", false); + queryDelimiter = getParamStyleDelimiter(queryStyle, "password", false); if (fullPath.indexOf("?") > 0) fullPath.append(queryPrefix); else @@ -506,7 +497,7 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::loginUserCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -546,7 +537,7 @@ void PFXUserApi::logoutUser() { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::logoutUserCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); } @@ -581,8 +572,8 @@ void PFXUserApi::updateUser(const QString &username, const PFXUser &body) { QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); QString pathPrefix, pathSuffix, pathDelimiter; - QString pathStyle = ""; - if(pathStyle == "") + QString pathStyle = ""; + if(pathStyle == "") pathStyle = "simple"; pathPrefix = getParamStylePrefix(pathStyle); pathSuffix = getParamStyleSuffix(pathStyle); @@ -602,7 +593,7 @@ void PFXUserApi::updateUser(const QString &username, const PFXUser &body) { foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); } connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::updateUserCallback); - connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); + connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); worker->execute(&input); }