Finished paramter styling(query,path,header,cookie) (#8587)

This commit is contained in:
basyskom-dege 2021-02-08 13:21:53 +01:00 committed by GitHub
parent df107e2244
commit 578420cfa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 819 additions and 68 deletions

View File

@ -206,7 +206,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✓|OAS3
|ParameterizedServer|✓|OAS3
|ParameterStyling||OAS3
|ParameterStyling||OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3

View File

@ -46,6 +46,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
.includeSecurityFeatures(SecurityFeature.BasicAuth)
.includeSecurityFeatures(SecurityFeature.ApiKey)
.includeSecurityFeatures(SecurityFeature.BearerToken)
.includeGlobalFeatures(GlobalFeature.ParameterStyling)
);
// set the output folder here

View File

@ -139,15 +139,73 @@ void {{classname}}::abortRequests(){
emit abortRequestsSignal();
}
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";
}
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";
}
QString {{classname}}::getParamStyleDelimiter(QString style, QString name, bool isExplode){
if(style == "matrix"){
return (isExplode) ? ";" + name + "=" : ",";
}else if(style == "label"){
return (isExplode) ? "." : ",";
}else if(style == "form"){
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 == "deepObject"){
return (isExplode) ? "&" : "none";
}else
return "none";
}
{{#operations}}
{{#operation}}
void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
QString fullPath = QString(_serverConfigs["{{nickname}}"][_serverIndices.value("{{nickname}}")].URL()+"{{{path}}}");
{{#pathParams}}
QString {{paramName}}PathParam("{");
{{paramName}}PathParam.append("{{baseName}}").append("}");
fullPath.replace({{paramName}}PathParam, QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}})));
{{/pathParams}}{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}}
{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}}
if(_apiKeys.contains("{{name}}")){
addHeaders("{{name}}",_apiKeys.find("{{name}}").value());
}
@ -168,18 +226,148 @@ void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName
b64.append(_username.toUtf8() + ":" + _password.toUtf8());
addHeaders("Authorization","Basic " + b64.toBase64());
}{{/isBasicBasic}}{{/authMethods}}
{{#queryParams}}{{^collectionFormat}}
{{#pathParams}}
QString {{paramName}}PathParam("{");
{{paramName}}PathParam.append("{{baseName}}").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "{{style}}";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "{{baseName}}", {{isExplode}});
{{^collectionFormat}}
{{^isPrimitiveType}}
QString paramString = (pathStyle == "matrix" && {{isExplode}}) ? pathPrefix : pathPrefix+"{{baseName}}"+pathSuffix;
QJsonObject parameter = {{paramName}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
pathDelimiter = (pathStyle == "matrix" && {{isExplode}}) ? ";" : getParamStyleDelimiter(pathStyle, key, {{isExplode}});
paramString.append(pathDelimiter);
}
QString assignOperator = ({{isExplode}}) ? "=" : ",";
switch(parameter.value(key).type()) {
case QJsonValue::String:
{
paramString.append(key+assignOperator+parameter.value(key).toString());
break;
}
case QJsonValue::Double:
{
paramString.append(key+assignOperator+QString::number(parameter.value(key).toDouble()));
break;
}
case QJsonValue::Bool:
{
paramString.append(key+assignOperator+QVariant(parameter.value(key).toBool()).toString());
break;
}
case QJsonValue::Array:
{
paramString.append(key+assignOperator+QVariant(parameter.value(key).toArray()).toString());
break;
}
case QJsonValue::Object:
{
paramString.append(key+assignOperator+QVariant(parameter.value(key).toObject()).toString());
break;
}
case QJsonValue::Null:
case QJsonValue::Undefined:
break;
}
count++;
}
fullPath.replace({{paramName}}PathParam, QUrl::toPercentEncoding(paramString));
{{/isPrimitiveType}}
{{#isPrimitiveType}}
QString paramString = (pathStyle == "matrix") ? pathPrefix+"{{baseName}}"+pathSuffix : pathPrefix;
fullPath.replace({{paramName}}PathParam, paramString+QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}})));
{{/isPrimitiveType}}{{/collectionFormat}}{{#collectionFormat}}
if ({{{paramName}}}.size() > 0) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"{{baseName}}"+pathSuffix : pathPrefix;
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
fullPath.append(pathDelimiter);
}
fullPath.append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue(t)));
count++;
}
fullPath.replace({{paramName}}PathParam, paramString);
}
{{/collectionFormat}}{{/pathParams}}
{{#hasQueryParams}}
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
{{/hasQueryParams}}
{{#queryParams}}
queryStyle = "{{style}}";
if(queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "{{baseName}}", {{isExplode}});
{{^collectionFormat}}
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("{{baseName}}")).append("=").append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}})));
{{/collectionFormat}}{{#collectionFormat}}
{{^isPrimitiveType}}
QString paramString = (queryStyle == "form" && {{isExplode}}) ? "" : (queryStyle == "form" && !({{isExplode}})) ? "{{baseName}}"+querySuffix : "";
QJsonObject parameter = {{paramName}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
queryDelimiter = ((queryStyle == "form" || queryStyle == "deepObject") && {{isExplode}}) ? "&" : getParamStyleDelimiter(queryStyle, key, {{isExplode}});
paramString.append(queryDelimiter);
}
QString assignOperator;
if (queryStyle == "form")
assignOperator = ({{isExplode}}) ? "=" : ",";
else if (queryStyle == "deepObject")
assignOperator = ({{isExplode}}) ? "=" : "none";
switch(parameter.value(key).type()) {
case QJsonValue::String:
{
paramString.append(((queryStyle == "form") ? key : QString("{{baseName}}").append("[").append(key).append("]"))+assignOperator+parameter.value(key).toString());
break;
}
case QJsonValue::Double:
{
paramString.append(((queryStyle == "form") ? key : QString("{{baseName}}").append("[").append(key).append("]"))+assignOperator+QString::number(parameter.value(key).toDouble()));
break;
}
case QJsonValue::Bool:
{
paramString.append(((queryStyle == "form") ? key : QString("{{baseName}}").append("[").append(key).append("]"))+assignOperator+QVariant(parameter.value(key).toBool()).toString());
break;
}
case QJsonValue::Array:
{
paramString.append(((queryStyle == "form") ? key : QString("{{baseName}}").append("[").append(key).append("]"))+assignOperator+QVariant(parameter.value(key).toArray()).toString());
break;
}
case QJsonValue::Object:
{
paramString.append(((queryStyle == "form") ? key : QString("{{baseName}}").append("[").append(key).append("]"))+assignOperator+QVariant(parameter.value(key).toObject()).toString());
break;
}
case QJsonValue::Null:
case QJsonValue::Undefined:
break;
}
count++;
}
fullPath.append(paramString);
{{/isPrimitiveType}}{{#isPrimitiveType}}
fullPath.append(QUrl::toPercentEncoding("{{baseName}}")).append(querySuffix).append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}})));
{{/isPrimitiveType}}{{/collectionFormat}}{{#collectionFormat}}
if ({{{paramName}}}.size() > 0) {
if (QString("{{collectionFormat}}").indexOf("multi") == 0) {
foreach ({{{baseType}}} t, {{paramName}}) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append("{{{baseName}}}=").append(::{{cppNamespace}}::toStringValue(t));
@ -188,27 +376,66 @@ void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("{{baseName}}=");
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
fullPath.append(" ");
fullPath.append(({{isExplode}})? queryDelimiter : QUrl::toPercentEncoding(queryDelimiter));
}
fullPath.append(::{{cppNamespace}}::toStringValue(t));
count++;
}
} else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("{{baseName}}=");
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
fullPath.append("\t");
}
fullPath.append(::{{cppNamespace}}::toStringValue(t));
count++;
}
} else if (QString("{{collectionFormat}}").indexOf("csv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::{{cppNamespace}}::toStringValue(t));
count++;
}
} else if (QString("{{collectionFormat}}").indexOf("pipes") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::{{cppNamespace}}::toStringValue(t));
count++;
}
} else if (QString("{{collectionFormat}}").indexOf("deepObject") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::{{cppNamespace}}::toStringValue(t));
count++;
}
}
}
@ -219,7 +446,18 @@ void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName
worker->setResponseCompressionEnabled(isResponseCompressionEnabled);
worker->setRequestCompressionEnabled(isRequestCompressionEnabled);{{/contentCompression}}
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
{{#formParams}}{{^isFile}}
{{#formParams}}
{{#first}}
QString formPrefix,formSuffix, formDelimiter;
QString formStyle = "{{style}}";
if(formStyle == "")
formStyle = "form";
formPrefix = getParamStylePrefix(formStyle);
formSuffix = getParamStyleSuffix(formStyle);
formDelimiter = getParamStyleDelimiter(formStyle, "{{baseName}}", {{isExplode}});
{{/first}}
{{^isFile}}
input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}));{{/isFile}}{{#isFile}}
input.add_file("{{baseName}}", {{paramName}}.local_filename, {{paramName}}.request_filename, {{paramName}}.mime_type);{{/isFile}}{{/formParams}}{{#bodyParams}}{{#isContainer}}{{#isArray}}
QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}).toArray());{{/isArray}}{{#isMap}}
@ -232,11 +470,130 @@ void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName
QByteArray output = {{paramName}}.asByteArray();{{/isFile}}
input.request_body.append(output);
{{/isContainer}}{{/bodyParams}}{{#headerParams}}
{{^collectionFormat}}{{^isPrimitiveType}}
QString headerString;
QJsonObject parameter = {{paramName}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
headerString.append(",");
}
QString assignOperator = ({{isExplode}}) ? "=" : ",";
switch(parameter.value(key).type()) {
case QJsonValue::String:
{
headerString.append(key+assignOperator+parameter.value(key).toString());
break;
}
case QJsonValue::Double:
{
headerString.append(key+assignOperator+QString::number(parameter.value(key).toDouble()));
break;
}
case QJsonValue::Bool:
{
headerString.append(key+assignOperator+QVariant(parameter.value(key).toBool()).toString());
break;
}
case QJsonValue::Array:
{
headerString.append(key+assignOperator+QVariant(parameter.value(key).toArray()).toString());
break;
}
case QJsonValue::Object:
{
headerString.append(key+assignOperator+QVariant(parameter.value(key).toObject()).toString());
break;
}
case QJsonValue::Null:
case QJsonValue::Undefined:
break;
}
count++;
}
input.headers.insert("{{baseName}}", headerString);
{{/isPrimitiveType}}{{#isPrimitiveType}}
if (!::{{cppNamespace}}::toStringValue({{paramName}}).isEmpty()) {
input.headers.insert("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}));
}
{{/isPrimitiveType}}{{/collectionFormat}}{{#collectionFormat}}
QString headerString;
if ({{{paramName}}}.size() > 0) {
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
headerString.append(",");
}
headerString.append(::{{cppNamespace}}::toStringValue(t));
count++;
}
input.headers.insert("{{baseName}}", headerString);
}
{{/collectionFormat}}
{{/headerParams}}
{{#cookieParams}}
if(QString("{{style}}").indexOf("form") == 0){
{{^collectionFormat}}{{^isPrimitiveType}}{{^isExplode}}
QString cookieString = "{{baseName}}=";
QJsonObject parameter = {{paramName}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
cookieString.append(",");
}
switch(parameter.value(key).type()) {
case QJsonValue::String:
{
cookieString.append(key+","+parameter.value(key).toString());
break;
}
case QJsonValue::Double:
{
cookieString.append(key+","+QString::number(parameter.value(key).toDouble()));
break;
}
case QJsonValue::Bool:
{
cookieString.append(key+","+QVariant(parameter.value(key).toBool()).toString());
break;
}
case QJsonValue::Array:
{
cookieString.append(key+","+QVariant(parameter.value(key).toArray()).toString());
break;
}
case QJsonValue::Object:
{
cookieString.append(key+","+QVariant(parameter.value(key).toObject()).toString());
break;
}
case QJsonValue::Null:
case QJsonValue::Undefined:
break;
}
count++;
}
input.headers.insert("Cookie", cookieString);
{{/isExplode}}{{/isPrimitiveType}}{{#isPrimitiveType}}
if (!::{{cppNamespace}}::toStringValue({{paramName}}).isEmpty()) {
input.headers.insert("Cookie", "{{baseName}}="+::{{cppNamespace}}::toStringValue({{paramName}}));
}
{{/isPrimitiveType}}{{/collectionFormat}}{{#collectionFormat}}{{^isExplode}}
QString cookieString = "{{baseName}}=";
if ({{{paramName}}}.size() > 0) {
qint32 count = 0;
foreach ({{{baseType}}} t, {{paramName}}) {
if (count > 0) {
cookieString.append(",");
}
cookieString.append(::{{cppNamespace}}::toStringValue(t));
count++;
}
input.headers.insert("Cookie", cookieString);
}
{{/isExplode}}{{/collectionFormat}}
}
{{/cookieParams}}
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);

View File

@ -43,6 +43,9 @@ public:
void enableRequestCompression();
void enableResponseCompression();
void abortRequests();
QString getParamStylePrefix(QString style);
QString getParamStyleSuffix(QString style);
QString getParamStyleDelimiter(QString style, QString name, bool isExplode);
{{#operations}}{{#operation}}
void {{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{/operation}}{{/operations}}

View File

@ -145,18 +145,81 @@ void PFXPetApi::abortRequests(){
emit abortRequestsSignal();
}
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";
}
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";
}
QString PFXPetApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){
if(style == "matrix"){
return (isExplode) ? ";" + name + "=" : ",";
}else if(style == "label"){
return (isExplode) ? "." : ",";
}else if(style == "form"){
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 == "deepObject"){
return (isExplode) ? "&" : "none";
}else
return "none";
}
void PFXPetApi::addPet(const PFXPet &body) {
QString fullPath = QString(_serverConfigs["addPet"][_serverIndices.value("addPet")].URL()+"/pet");
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
QByteArray output = body.asJson().toUtf8();
input.request_body.append(output);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback);
@ -188,9 +251,18 @@ void PFXPetApi::addPetCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::deletePet(const qint64 &pet_id, const QString &api_key) {
QString fullPath = QString(_serverConfigs["deletePet"][_serverIndices.value("deletePet")].URL()+"/pet/{petId}");
QString pet_idPathParam("{");
pet_idPathParam.append("petId").append("}");
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "petId", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -198,10 +270,11 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const QString &api_key) {
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "DELETE");
if (!::test_namespace::toStringValue(api_key).isEmpty()) {
input.headers.insert("api_key", ::test_namespace::toStringValue(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);
@ -235,11 +308,19 @@ void PFXPetApi::findPetsByStatus(const QList<QString> &status) {
QString fullPath = QString(_serverConfigs["findPetsByStatus"][_serverIndices.value("findPetsByStatus")].URL()+"/pet/findByStatus");
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
queryStyle = "form";
if(queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "status", false);
if (status.size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach (QString t, status) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append("status=").append(::test_namespace::toStringValue(t));
@ -248,27 +329,66 @@ void PFXPetApi::findPetsByStatus(const QList<QString> &status) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("status=");
fullPath.append("?").append(queryPrefix).append("status").append(querySuffix);
qint32 count = 0;
foreach (QString t, status) {
if (count > 0) {
fullPath.append(" ");
fullPath.append((false)? queryDelimiter : QUrl::toPercentEncoding(queryDelimiter));
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("status=");
fullPath.append("?").append(queryPrefix).append("status").append(querySuffix);
qint32 count = 0;
foreach (QString t, status) {
if (count > 0) {
fullPath.append("\t");
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("csv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("status").append(querySuffix);
qint32 count = 0;
foreach (QString t, status) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("pipes") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("status").append(querySuffix);
qint32 count = 0;
foreach (QString t, status) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("deepObject") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("status").append(querySuffix);
qint32 count = 0;
foreach (QString t, status) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
}
}
@ -321,11 +441,19 @@ void PFXPetApi::findPetsByTags(const QList<QString> &tags) {
QString fullPath = QString(_serverConfigs["findPetsByTags"][_serverIndices.value("findPetsByTags")].URL()+"/pet/findByTags");
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
queryStyle = "form";
if(queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "tags", false);
if (tags.size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach (QString t, tags) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append("tags=").append(::test_namespace::toStringValue(t));
@ -334,27 +462,66 @@ void PFXPetApi::findPetsByTags(const QList<QString> &tags) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("tags=");
fullPath.append("?").append(queryPrefix).append("tags").append(querySuffix);
qint32 count = 0;
foreach (QString t, tags) {
if (count > 0) {
fullPath.append(" ");
fullPath.append((false)? queryDelimiter : QUrl::toPercentEncoding(queryDelimiter));
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("tags=");
fullPath.append("?").append(queryPrefix).append("tags").append(querySuffix);
qint32 count = 0;
foreach (QString t, tags) {
if (count > 0) {
fullPath.append("\t");
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("csv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("tags").append(querySuffix);
qint32 count = 0;
foreach (QString t, tags) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("pipes") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("tags").append(querySuffix);
qint32 count = 0;
foreach (QString t, tags) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("deepObject") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("tags").append(querySuffix);
qint32 count = 0;
foreach (QString t, tags) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::test_namespace::toStringValue(t));
count++;
}
}
}
@ -405,14 +572,23 @@ void PFXPetApi::findPetsByTagsCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::getPetById(const qint64 &pet_id) {
QString fullPath = QString(_serverConfigs["getPetById"][_serverIndices.value("getPetById")].URL()+"/pet/{petId}");
QString pet_idPathParam("{");
pet_idPathParam.append("petId").append("}");
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
if(_apiKeys.contains("api_key")){
addHeaders("api_key",_apiKeys.find("api_key").value());
}
QString pet_idPathParam("{");
pet_idPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "petId", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
@ -453,14 +629,15 @@ void PFXPetApi::updatePet(const PFXPet &body) {
QString fullPath = QString(_serverConfigs["updatePet"][_serverIndices.value("updatePet")].URL()+"/pet");
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "PUT");
QByteArray output = body.asJson().toUtf8();
input.request_body.append(output);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetCallback);
@ -492,9 +669,18 @@ void PFXPetApi::updatePetCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QString &name, const QString &status) {
QString fullPath = QString(_serverConfigs["updatePetWithForm"][_serverIndices.value("updatePetWithForm")].URL()+"/pet/{petId}");
QString pet_idPathParam("{");
pet_idPathParam.append("petId").append("}");
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "petId", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -502,9 +688,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QString &name, con
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
input.add_var("name", ::test_namespace::toStringValue(name));
input.add_var("status", ::test_namespace::toStringValue(status));
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
input.add_var("name", ::test_namespace::toStringValue(name)); input.add_var("status", ::test_namespace::toStringValue(status)); 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);
@ -535,9 +719,18 @@ void PFXPetApi::updatePetWithFormCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::uploadFile(const qint64 &pet_id, const QString &additional_metadata, const PFXHttpFileElement &file) {
QString fullPath = QString(_serverConfigs["uploadFile"][_serverIndices.value("uploadFile")].URL()+"/pet/{petId}/uploadImage");
QString pet_idPathParam("{");
pet_idPathParam.append("petId").append("}");
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "petId", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -546,8 +739,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const QString &additional_metad
PFXHttpRequestInput input(fullPath, "POST");
input.add_var("additionalMetadata", ::test_namespace::toStringValue(additional_metadata));
input.add_file("file", file.local_filename, file.request_filename, file.mime_type);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
input.add_file("file", file.local_filename, file.request_filename, file.mime_type); 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);

View File

@ -53,6 +53,9 @@ public:
void enableRequestCompression();
void enableResponseCompression();
void abortRequests();
QString getParamStylePrefix(QString style);
QString getParamStyleSuffix(QString style);
QString getParamStyleDelimiter(QString style, QString name, bool isExplode);
void addPet(const PFXPet &body);
void deletePet(const qint64 &pet_id, const QString &api_key);

View File

@ -133,11 +133,82 @@ void PFXStoreApi::abortRequests(){
emit abortRequestsSignal();
}
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";
}
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";
}
QString PFXStoreApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){
if(style == "matrix"){
return (isExplode) ? ";" + name + "=" : ",";
}else if(style == "label"){
return (isExplode) ? "." : ",";
}else if(style == "form"){
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 == "deepObject"){
return (isExplode) ? "&" : "none";
}else
return "none";
}
void PFXStoreApi::deleteOrder(const QString &order_id) {
QString fullPath = QString(_serverConfigs["deleteOrder"][_serverIndices.value("deleteOrder")].URL()+"/store/order/{orderId}");
QString order_idPathParam("{");
order_idPathParam.append("orderId").append("}");
fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "orderId", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"orderId"+pathSuffix : pathPrefix;
fullPath.replace(order_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -182,6 +253,7 @@ void PFXStoreApi::getInventory() {
}
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
@ -228,9 +300,18 @@ void PFXStoreApi::getInventoryCallback(PFXHttpRequestWorker *worker) {
void PFXStoreApi::getOrderById(const qint64 &order_id) {
QString fullPath = QString(_serverConfigs["getOrderById"][_serverIndices.value("getOrderById")].URL()+"/store/order/{orderId}");
QString order_idPathParam("{");
order_idPathParam.append("orderId").append("}");
fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "orderId", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"orderId"+pathSuffix : pathPrefix;
fullPath.replace(order_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -272,14 +353,15 @@ void PFXStoreApi::placeOrder(const PFXOrder &body) {
QString fullPath = QString(_serverConfigs["placeOrder"][_serverIndices.value("placeOrder")].URL()+"/store/order");
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
QByteArray output = body.asJson().toUtf8();
input.request_body.append(output);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::placeOrderCallback);

View File

@ -52,6 +52,9 @@ public:
void enableRequestCompression();
void enableResponseCompression();
void abortRequests();
QString getParamStylePrefix(QString style);
QString getParamStyleSuffix(QString style);
QString getParamStyleDelimiter(QString style, QString name, bool isExplode);
void deleteOrder(const QString &order_id);
void getInventory();

View File

@ -145,18 +145,81 @@ void PFXUserApi::abortRequests(){
emit abortRequestsSignal();
}
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";
}
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";
}
QString PFXUserApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){
if(style == "matrix"){
return (isExplode) ? ";" + name + "=" : ",";
}else if(style == "label"){
return (isExplode) ? "." : ",";
}else if(style == "form"){
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 == "deepObject"){
return (isExplode) ? "&" : "none";
}else
return "none";
}
void PFXUserApi::createUser(const PFXUser &body) {
QString fullPath = QString(_serverConfigs["createUser"][_serverIndices.value("createUser")].URL()+"/user");
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
QByteArray output = body.asJson().toUtf8();
input.request_body.append(output);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUserCallback);
@ -190,15 +253,16 @@ void PFXUserApi::createUsersWithArrayInput(const QList<PFXUser> &body) {
QString fullPath = QString(_serverConfigs["createUsersWithArrayInput"][_serverIndices.value("createUsersWithArrayInput")].URL()+"/user/createWithArray");
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithArrayInputCallback);
@ -232,15 +296,16 @@ void PFXUserApi::createUsersWithListInput(const QList<PFXUser> &body) {
QString fullPath = QString(_serverConfigs["createUsersWithListInput"][_serverIndices.value("createUsersWithListInput")].URL()+"/user/createWithList");
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithListInputCallback);
@ -272,9 +337,18 @@ void PFXUserApi::createUsersWithListInputCallback(PFXHttpRequestWorker *worker)
void PFXUserApi::deleteUser(const QString &username) {
QString fullPath = QString(_serverConfigs["deleteUser"][_serverIndices.value("deleteUser")].URL()+"/user/{username}");
QString usernamePathParam("{");
usernamePathParam.append("username").append("}");
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "username", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"username"+pathSuffix : pathPrefix;
fullPath.replace(usernamePathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -313,9 +387,18 @@ void PFXUserApi::deleteUserCallback(PFXHttpRequestWorker *worker) {
void PFXUserApi::getUserByName(const QString &username) {
QString fullPath = QString(_serverConfigs["getUserByName"][_serverIndices.value("getUserByName")].URL()+"/user/{username}");
QString usernamePathParam("{");
usernamePathParam.append("username").append("}");
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "username", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"username"+pathSuffix : pathPrefix;
fullPath.replace(usernamePathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -357,17 +440,31 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) {
QString fullPath = QString(_serverConfigs["loginUser"][_serverIndices.value("loginUser")].URL()+"/user/login");
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
queryStyle = "";
if(queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "username", false);
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("username")).append("=").append(QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
fullPath.append(QUrl::toPercentEncoding("username")).append(querySuffix).append(QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
queryStyle = "";
if(queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "password", false);
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("password")).append("=").append(QUrl::toPercentEncoding(::test_namespace::toStringValue(password)));
fullPath.append(QUrl::toPercentEncoding("password")).append(querySuffix).append(QUrl::toPercentEncoding(::test_namespace::toStringValue(password)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
@ -409,6 +506,7 @@ void PFXUserApi::logoutUser() {
QString fullPath = QString(_serverConfigs["logoutUser"][_serverIndices.value("logoutUser")].URL()+"/user/logout");
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
@ -445,9 +543,18 @@ void PFXUserApi::logoutUserCallback(PFXHttpRequestWorker *worker) {
void PFXUserApi::updateUser(const QString &username, const PFXUser &body) {
QString fullPath = QString(_serverConfigs["updateUser"][_serverIndices.value("updateUser")].URL()+"/user/{username}");
QString usernamePathParam("{");
usernamePathParam.append("username").append("}");
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
if(pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "username", false);
QString paramString = (pathStyle == "matrix") ? pathPrefix+"username"+pathSuffix : pathPrefix;
fullPath.replace(usernamePathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
@ -455,9 +562,9 @@ void PFXUserApi::updateUser(const QString &username, const PFXUser &body) {
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "PUT");
QByteArray output = body.asJson().toUtf8();
input.request_body.append(output);
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::updateUserCallback);

View File

@ -52,6 +52,9 @@ public:
void enableRequestCompression();
void enableResponseCompression();
void abortRequests();
QString getParamStylePrefix(QString style);
QString getParamStyleSuffix(QString style);
QString getParamStyleDelimiter(QString style, QString name, bool isExplode);
void createUser(const PFXUser &body);
void createUsersWithArrayInput(const QList<PFXUser> &body);