forked from loafle/openapi-generator-original
fix file support in form parameter (qt5cpp)
This commit is contained in:
parent
f42f9acf35
commit
d5aa285926
@ -29,7 +29,7 @@ void
|
|||||||
|
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
{{^collectionFormat}}
|
{{^collectionFormat}}
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
@ -40,10 +40,10 @@ void
|
|||||||
|
|
||||||
{{#collectionFormat}}
|
{{#collectionFormat}}
|
||||||
|
|
||||||
if({{{paramName}}}->size() > 0) {
|
if ({{{paramName}}}->size() > 0) {
|
||||||
if(QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
if (QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
||||||
foreach({{{baseType}}} t, *{{paramName}}) {
|
foreach({{{baseType}}} t, *{{paramName}}) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
@ -51,28 +51,28 @@ void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (QString("{{collectionFormat}}").indexOf("ssv") == 0) {
|
else if (QString("{{collectionFormat}}").indexOf("ssv") == 0) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
fullPath.append("{{paramName}}=");
|
fullPath.append("{{paramName}}=");
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
foreach({{{baseType}}} t, *{{paramName}}) {
|
foreach({{{baseType}}} t, *{{paramName}}) {
|
||||||
if(count > 0) {
|
if (count > 0) {
|
||||||
fullPath.append(" ");
|
fullPath.append(" ");
|
||||||
}
|
}
|
||||||
fullPath.append(stringValue(t));
|
fullPath.append(stringValue(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) {
|
else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
fullPath.append("{{paramName}}=");
|
fullPath.append("{{paramName}}=");
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
foreach({{{baseType}}} t, *{{paramName}}) {
|
foreach({{{baseType}}} t, *{{paramName}}) {
|
||||||
if(count > 0) {
|
if (count > 0) {
|
||||||
fullPath.append("\t");
|
fullPath.append("\t");
|
||||||
}
|
}
|
||||||
fullPath.append(stringValue(t));
|
fullPath.append(stringValue(t));
|
||||||
@ -86,11 +86,10 @@ void
|
|||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "{{httpMethod}}");
|
HttpRequestInput input(fullPath, "{{httpMethod}}");
|
||||||
|
|
||||||
{{#formParams}}{{^isFile}}
|
{{#formParams}}if ({{paramName}} != NULL) {
|
||||||
if({{paramName}} != NULL) {
|
{{^isFile}}input.add_var("{{paramName}}", *{{paramName}});{{/isFile}}{{#isFile}}input.add_file("{{paramName}}", *{{paramName}}.local_filename, *{{paramName}}.request_filename, *{{paramName}}.mime_type);{{/isFile}}
|
||||||
input.add_var("{{paramName}}", *{{paramName}});
|
|
||||||
}
|
}
|
||||||
{{/isFile}}{{/formParams}}
|
{{/formParams}}
|
||||||
|
|
||||||
{{#bodyParams}}
|
{{#bodyParams}}
|
||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include "SWGCategory.h"
|
#include "SWGCategory.h"
|
||||||
#include <QList>
|
|
||||||
#include "SWGTag.h"
|
#include "SWGTag.h"
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include "SWGObject.h"
|
#include "SWGObject.h"
|
||||||
|
|
||||||
|
@ -123,10 +123,10 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(status->size() > 0) {
|
if (status->size() > 0) {
|
||||||
if(QString("multi").indexOf("multi") == 0) {
|
if (QString("multi").indexOf("multi") == 0) {
|
||||||
foreach(QString* t, *status) {
|
foreach(QString* t, *status) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
@ -134,28 +134,28 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (QString("multi").indexOf("ssv") == 0) {
|
else if (QString("multi").indexOf("ssv") == 0) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
fullPath.append("status=");
|
fullPath.append("status=");
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
foreach(QString* t, *status) {
|
foreach(QString* t, *status) {
|
||||||
if(count > 0) {
|
if (count > 0) {
|
||||||
fullPath.append(" ");
|
fullPath.append(" ");
|
||||||
}
|
}
|
||||||
fullPath.append(stringValue(t));
|
fullPath.append(stringValue(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (QString("multi").indexOf("tsv") == 0) {
|
else if (QString("multi").indexOf("tsv") == 0) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
fullPath.append("status=");
|
fullPath.append("status=");
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
foreach(QString* t, *status) {
|
foreach(QString* t, *status) {
|
||||||
if(count > 0) {
|
if (count > 0) {
|
||||||
fullPath.append("\t");
|
fullPath.append("\t");
|
||||||
}
|
}
|
||||||
fullPath.append(stringValue(t));
|
fullPath.append(stringValue(t));
|
||||||
@ -228,10 +228,10 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(tags->size() > 0) {
|
if (tags->size() > 0) {
|
||||||
if(QString("multi").indexOf("multi") == 0) {
|
if (QString("multi").indexOf("multi") == 0) {
|
||||||
foreach(QString* t, *tags) {
|
foreach(QString* t, *tags) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
@ -239,28 +239,28 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (QString("multi").indexOf("ssv") == 0) {
|
else if (QString("multi").indexOf("ssv") == 0) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
fullPath.append("tags=");
|
fullPath.append("tags=");
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
foreach(QString* t, *tags) {
|
foreach(QString* t, *tags) {
|
||||||
if(count > 0) {
|
if (count > 0) {
|
||||||
fullPath.append(" ");
|
fullPath.append(" ");
|
||||||
}
|
}
|
||||||
fullPath.append(stringValue(t));
|
fullPath.append(stringValue(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (QString("multi").indexOf("tsv") == 0) {
|
else if (QString("multi").indexOf("tsv") == 0) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
fullPath.append("tags=");
|
fullPath.append("tags=");
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
foreach(QString* t, *tags) {
|
foreach(QString* t, *tags) {
|
||||||
if(count > 0) {
|
if (count > 0) {
|
||||||
fullPath.append("\t");
|
fullPath.append("\t");
|
||||||
}
|
}
|
||||||
fullPath.append(stringValue(t));
|
fullPath.append(stringValue(t));
|
||||||
@ -391,12 +391,10 @@ SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) {
|
|||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
HttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
if (name != NULL) {
|
||||||
if(name != NULL) {
|
|
||||||
input.add_var("name", *name);
|
input.add_var("name", *name);
|
||||||
}
|
}
|
||||||
|
if (status != NULL) {
|
||||||
if(status != NULL) {
|
|
||||||
input.add_var("status", *status);
|
input.add_var("status", *status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,10 +491,12 @@ SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestI
|
|||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
HttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
if (additionalMetadata != NULL) {
|
||||||
if(additionalMetadata != NULL) {
|
|
||||||
input.add_var("additionalMetadata", *additionalMetadata);
|
input.add_var("additionalMetadata", *additionalMetadata);
|
||||||
}
|
}
|
||||||
|
if (file != NULL) {
|
||||||
|
input.add_file("file", *file.local_filename, *file.request_filename, *file.mime_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -528,4 +528,107 @@ SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
|
|||||||
|
|
||||||
emit uploadFileSignal();
|
emit uploadFileSignal();
|
||||||
}
|
}
|
||||||
|
void
|
||||||
|
SWGPetApi::getPetByIdWithByteArray(qint64 petId) {
|
||||||
|
QString fullPath;
|
||||||
|
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}?testing_byte_array=true");
|
||||||
|
|
||||||
|
|
||||||
|
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
|
||||||
|
fullPath.replace(petIdPathParam, stringValue(petId));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
|
HttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
connect(worker,
|
||||||
|
&HttpRequestWorker::on_execution_finished,
|
||||||
|
this,
|
||||||
|
&SWGPetApi::getPetByIdWithByteArrayCallback);
|
||||||
|
|
||||||
|
worker->execute(&input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGPetApi::getPetByIdWithByteArrayCallback(HttpRequestWorker * worker) {
|
||||||
|
QString msg;
|
||||||
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = "Error: " + worker->error_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QString json(worker->response);
|
||||||
|
QString* output = static_cast<QString*>(create(json, QString("QString")));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
worker->deleteLater();
|
||||||
|
|
||||||
|
emit getPetByIdWithByteArraySignal(output);
|
||||||
|
|
||||||
|
}
|
||||||
|
void
|
||||||
|
SWGPetApi::addPetUsingByteArray(QString* body) {
|
||||||
|
QString fullPath;
|
||||||
|
fullPath.append(this->host).append(this->basePath).append("/pet?testing_byte_array=true");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
|
HttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QString output = body.asJson();
|
||||||
|
input.request_body.append(output);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
connect(worker,
|
||||||
|
&HttpRequestWorker::on_execution_finished,
|
||||||
|
this,
|
||||||
|
&SWGPetApi::addPetUsingByteArrayCallback);
|
||||||
|
|
||||||
|
worker->execute(&input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGPetApi::addPetUsingByteArrayCallback(HttpRequestWorker * worker) {
|
||||||
|
QString msg;
|
||||||
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = "Error: " + worker->error_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
worker->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
|
emit addPetUsingByteArraySignal();
|
||||||
|
}
|
||||||
} /* namespace Swagger */
|
} /* namespace Swagger */
|
||||||
|
@ -30,6 +30,8 @@ public:
|
|||||||
void updatePetWithForm(QString* petId, QString* name, QString* status);
|
void updatePetWithForm(QString* petId, QString* name, QString* status);
|
||||||
void deletePet(qint64 petId, QString* apiKey);
|
void deletePet(qint64 petId, QString* apiKey);
|
||||||
void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
|
void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
|
||||||
|
void getPetByIdWithByteArray(qint64 petId);
|
||||||
|
void addPetUsingByteArray(QString* body);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updatePetCallback (HttpRequestWorker * worker);
|
void updatePetCallback (HttpRequestWorker * worker);
|
||||||
@ -40,6 +42,8 @@ private:
|
|||||||
void updatePetWithFormCallback (HttpRequestWorker * worker);
|
void updatePetWithFormCallback (HttpRequestWorker * worker);
|
||||||
void deletePetCallback (HttpRequestWorker * worker);
|
void deletePetCallback (HttpRequestWorker * worker);
|
||||||
void uploadFileCallback (HttpRequestWorker * worker);
|
void uploadFileCallback (HttpRequestWorker * worker);
|
||||||
|
void getPetByIdWithByteArrayCallback (HttpRequestWorker * worker);
|
||||||
|
void addPetUsingByteArrayCallback (HttpRequestWorker * worker);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updatePetSignal();
|
void updatePetSignal();
|
||||||
@ -50,6 +54,8 @@ signals:
|
|||||||
void updatePetWithFormSignal();
|
void updatePetWithFormSignal();
|
||||||
void deletePetSignal();
|
void deletePetSignal();
|
||||||
void uploadFileSignal();
|
void uploadFileSignal();
|
||||||
|
void getPetByIdWithByteArraySignal(QString* summary);
|
||||||
|
void addPetUsingByteArraySignal();
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
@ -190,7 +190,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
fullPath.append("?");
|
fullPath.append("?");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user