Revision control
/**
* OpenAPI Petstore
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit the class manually.
*/
#include "OAIPetApi.h"
#include "OAIServerConfiguration.h"
#include <QtCore/qanystringview.h>
#include <QtCore/qjsonarray.h>
#include <QtCore/qjsondocument.h>
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtNetwork/qnetworkreply.h>
#include <QtNetwork/qnetworkrequestfactory.h>
#include <QtNetwork/qrestaccessmanager.h>
using namespace Qt::StringLiterals;
namespace OpenAPI {
OAIPetApi::OAIPetApi(QObject *parent)
: OAIBaseApi(parent)
{
initializeServerConfigs();
}
OAIPetApi::~OAIPetApi()
{
}
void OAIPetApi::initializeServerConfigs()
{
//Default server
QList<OAIServerConfiguration> defaultConf = QList<OAIServerConfiguration>();
//varying endpoint server
defaultConf.append(OAIServerConfiguration(
QUrl("http://127.0.0.1:9080/v2"),
"No description provided",
QMap<QString, OAIServerVariable>()));
m_serverConfigs.insert("addPet", defaultConf);
m_serverIndices.insert("addPet", 0);
m_serverConfigs.insert("deletePet", defaultConf);
m_serverIndices.insert("deletePet", 0);
m_serverConfigs.insert("findPetsByAgeAndPatience", defaultConf);
m_serverIndices.insert("findPetsByAgeAndPatience", 0);
m_serverConfigs.insert("findPetsByStatus", defaultConf);
m_serverIndices.insert("findPetsByStatus", 0);
m_serverConfigs.insert("findPetsByTags", defaultConf);
m_serverIndices.insert("findPetsByTags", 0);
m_serverConfigs.insert("findPetsImageById", defaultConf);
m_serverIndices.insert("findPetsImageById", 0);
m_serverConfigs.insert("getJsonFile", defaultConf);
m_serverIndices.insert("getJsonFile", 0);
m_serverConfigs.insert("getPetById", defaultConf);
m_serverIndices.insert("getPetById", 0);
m_serverConfigs.insert("updatePet", defaultConf);
m_serverIndices.insert("updatePet", 0);
m_serverConfigs.insert("updatePetWithForm", defaultConf);
m_serverIndices.insert("updatePetWithForm", 0);
m_serverConfigs.insert("uploadFile", defaultConf);
m_serverIndices.insert("uploadFile", 0);
}
/**
* \fn virtual void OAIPetApi::addPet(const OAIPet &oAIPet)
* 'addPet' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] oAIPet OAIPet [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::addPet(const OAIPet &oAIPet, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'addPet' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * addPet(oAIPet, this, [&](QRestReply &reply, OAIPet &summary) { if (reply.isSuccess()) ... });
+ * addPet(oAIPet, this, [&](const QRestReply &reply, const OAIPet &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual addPetWithDataImpl() in derived class.
* The virtual addPetWithDataImpl() is being called by the template
* function.
* @param[in] oAIPet OAIPet [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::addPetCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by addPetFinished() or
* being returned as a callback parameter of addPet() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::addPetWithDataImpl(const OAIPet &oAIPet, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the addPet() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking addPet() operation calls.
* @param[in] oAIPet OAIPet [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::addPetWithDataImpl(const OAIPet &oAIPet, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["addPet"][m_serverIndices.value("addPet")].serverUrl();
QString fullPath = "/pet";
m_networkFactory->setBaseUrl(serverUrl);
if (!m_username.isEmpty() && !m_password.isEmpty()) {
QByteArray b64;
b64.append(m_username.toUtf8() + ":" + m_password.toUtf8());
setHeader(QHttpHeaders::WellKnownHeader::Authorization, QAnyStringView("Basic "_L1 + b64.toBase64()));
}
OAIHttpRequestInput input(fullPath, "POST");
{
QByteArray output = oAIPet.asJson().toUtf8();
input.m_requestBody.append(output);
}
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
addPetCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit addPetErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
OAIPet empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::addPetCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
OAIPet output(response);
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit addPetFinished(output);
}
/**
* \fn virtual void OAIPetApi::deletePet(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &apiKey = ::OpenAPI::OptionalParam<QString>())
* 'deletePet' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] petId qint64 [required]
* @param[in] apiKey QString [optional]
*/
/**
* \fn template < Functor, > void OAIPetApi::deletePet(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &apiKey = ::OpenAPI::OptionalParam<QString>(), const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'deletePet' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * deletePet(petId, apiKey, this, [&](QRestReply &reply) { if (reply.isSuccess()) ... });
+ * deletePet(petId, apiKey, this, [&](const QRestReply &reply) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual deletePetWithDataImpl() in derived class.
* The virtual deletePetWithDataImpl() is being called by the template
* function.
* @param[in] petId qint64 [required]
* @param[in] apiKey QString [optional]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::deletePetCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by deletePetFinished() or
* being returned as a callback parameter of deletePet() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::deletePetWithDataImpl(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &apiKey, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the deletePet() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking deletePet() operation calls.
* @param[in] petId qint64 [required]
* @param[in] apiKey QString [optional]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::deletePetWithDataImpl(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &apiKey, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["deletePet"][m_serverIndices.value("deletePet")].serverUrl();
QString fullPath = "/pet/{petId}";
m_networkFactory->setBaseUrl(serverUrl);
if (!m_bearerToken.isEmpty())
setHeader(QHttpHeaders::WellKnownHeader::Authorization, QAnyStringView("Bearer "_L1 + m_bearerToken));
QString petIdPathParam("{");
petIdPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "simple";
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(petIdPathParam, QUrl::toPercentEncoding(paramString + ::OpenAPI::toStringValue(petId)));
OAIHttpRequestInput input(fullPath, "DELETE");
if (apiKey.hasValue()) {
if (!::OpenAPI::toStringValue(apiKey.value()).isEmpty()) {
QAnyStringView paramValue = QAnyStringView(::OpenAPI::toStringValue(apiKey.value()));
input.m_headers.replaceOrAppend("api_key"_L1, paramValue);
}
}
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
deletePetCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit deletePetErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::deletePetCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply) };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit deletePetFinished();
}
/**
* \fn virtual void OAIPetApi::findPetsByAgeAndPatience(const QList<qint32> &petData)
* 'findPetsByAgeAndPatience' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] petData QList<qint32> [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::findPetsByAgeAndPatience(const QList<qint32> &petData, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'findPetsByAgeAndPatience' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * findPetsByAgeAndPatience(petData, this, [&](QRestReply &reply, QList<OAIPet> &summary) { if (reply.isSuccess()) ... });
+ * findPetsByAgeAndPatience(petData, this, [&](const QRestReply &reply, const QList<OAIPet> &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual findPetsByAgeAndPatienceWithDataImpl() in derived class.
* The virtual findPetsByAgeAndPatienceWithDataImpl() is being called by the template
* function.
* @param[in] petData QList<qint32> [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::findPetsByAgeAndPatienceCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by findPetsByAgeAndPatienceFinished() or
* being returned as a callback parameter of findPetsByAgeAndPatience() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::findPetsByAgeAndPatienceWithDataImpl(const QList<qint32> &petData, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the findPetsByAgeAndPatience() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking findPetsByAgeAndPatience() operation calls.
* @param[in] petData QList<qint32> [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::findPetsByAgeAndPatienceWithDataImpl(const QList<qint32> &petData, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["findPetsByAgeAndPatience"][m_serverIndices.value("findPetsByAgeAndPatience")].serverUrl();
QString fullPath = "/pet/findPetsByAgeAndPatience/{petData}";
m_networkFactory->setBaseUrl(serverUrl);
QString petDataPathParam("{");
petDataPathParam.append("petData").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "simple";
if (pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
pathDelimiter = getParamStyleDelimiter(pathStyle, "petData", false);
if (petData.size() > 0) {
QString paramString = (pathStyle == "matrix") ? pathPrefix + "petData" + pathSuffix : pathPrefix;
qint32 count = 0;
for (qint32 t : petData) {
if (count > 0) {
fullPath.append(pathDelimiter);
}
fullPath.append(QUrl::toPercentEncoding(::OpenAPI::toStringValue(t)));
count++;
}
fullPath.replace(petDataPathParam, paramString);
}
OAIHttpRequestInput input(fullPath, "GET");
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
findPetsByAgeAndPatienceCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit findPetsByAgeAndPatienceErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
QList<OAIPet> empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::findPetsByAgeAndPatienceCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
QList<OAIPet> output;
const QString json(response);
QByteArray array(json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonArray jsonArray = doc.array();
for (QJsonValue obj : jsonArray) {
OAIPet val;
::OpenAPI::fromJsonValue(val, obj);
output.append(val);
}
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit findPetsByAgeAndPatienceFinished(output);
}
/**
* \fn virtual void OAIPetApi::findPetsByStatus(const QList<QString> &status)
* 'findPetsByStatus' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] status QList<QString> [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::findPetsByStatus(const QList<QString> &status, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'findPetsByStatus' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * findPetsByStatus(status, this, [&](QRestReply &reply, QList<OAIPet> &summary) { if (reply.isSuccess()) ... });
+ * findPetsByStatus(status, this, [&](const QRestReply &reply, const QList<OAIPet> &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual findPetsByStatusWithDataImpl() in derived class.
* The virtual findPetsByStatusWithDataImpl() is being called by the template
* function.
* @param[in] status QList<QString> [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::findPetsByStatusCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by findPetsByStatusFinished() or
* being returned as a callback parameter of findPetsByStatus() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::findPetsByStatusWithDataImpl(const QList<QString> &status, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the findPetsByStatus() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking findPetsByStatus() operation calls.
* @param[in] status QList<QString> [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::findPetsByStatusWithDataImpl(const QList<QString> &status, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["findPetsByStatus"][m_serverIndices.value("findPetsByStatus")].serverUrl();
QString fullPath = "/pet/findByStatus";
m_networkFactory->setBaseUrl(serverUrl);
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) {
for (QString t : status) {
if (fullPath.indexOf("?") > 0)
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append("status=").append(::OpenAPI::toStringValue(t));
}
} else if (QString("csv").indexOf("ssv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("status").append(querySuffix);
qint32 count = 0;
for (QString t : status) {
if (count > 0) {
fullPath.append((false)? queryDelimiter : QUrl::toPercentEncoding(queryDelimiter));
}
fullPath.append(::OpenAPI::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("status").append(querySuffix);
qint32 count = 0;
for (QString t : status) {
if (count > 0) {
fullPath.append("\t");
}
fullPath.append(::OpenAPI::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;
for (QString t : status) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::OpenAPI::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;
for (QString t : status) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::OpenAPI::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;
for (QString t : status) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::OpenAPI::toStringValue(t));
count++;
}
}
}
}
OAIHttpRequestInput input(fullPath, "GET");
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
findPetsByStatusCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit findPetsByStatusErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
QList<OAIPet> empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::findPetsByStatusCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
QList<OAIPet> output;
const QString json(response);
QByteArray array(json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonArray jsonArray = doc.array();
for (QJsonValue obj : jsonArray) {
OAIPet val;
::OpenAPI::fromJsonValue(val, obj);
output.append(val);
}
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit findPetsByStatusFinished(output);
}
/**
* \fn virtual void OAIPetApi::findPetsByTags(const QList<QString> &tags)
* \deprecated 'findPetsByTags' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] tags QList<QString> [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::findPetsByTags(const QList<QString> &tags, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* \deprecated 'findPetsByTags' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * findPetsByTags(tags, this, [&](QRestReply &reply, QList<OAIPet> &summary) { if (reply.isSuccess()) ... });
+ * findPetsByTags(tags, this, [&](const QRestReply &reply, const QList<OAIPet> &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual findPetsByTagsWithDataImpl() in derived class.
* The virtual findPetsByTagsWithDataImpl() is being called by the template
* function.
* @param[in] tags QList<QString> [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::findPetsByTagsCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by findPetsByTagsFinished() or
* being returned as a callback parameter of findPetsByTags() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::findPetsByTagsWithDataImpl(const QList<QString> &tags, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the findPetsByTags() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking findPetsByTags() operation calls.
* @param[in] tags QList<QString> [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::findPetsByTagsWithDataImpl(const QList<QString> &tags, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["findPetsByTags"][m_serverIndices.value("findPetsByTags")].serverUrl();
QString fullPath = "/pet/findByTags";
m_networkFactory->setBaseUrl(serverUrl);
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) {
for (QString t : tags) {
if (fullPath.indexOf("?") > 0)
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append("tags=").append(::OpenAPI::toStringValue(t));
}
} else if (QString("csv").indexOf("ssv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("tags").append(querySuffix);
qint32 count = 0;
for (QString t : tags) {
if (count > 0) {
fullPath.append((false)? queryDelimiter : QUrl::toPercentEncoding(queryDelimiter));
}
fullPath.append(::OpenAPI::toStringValue(t));
count++;
}
} else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?").append(queryPrefix).append("tags").append(querySuffix);
qint32 count = 0;
for (QString t : tags) {
if (count > 0) {
fullPath.append("\t");
}
fullPath.append(::OpenAPI::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;
for (QString t : tags) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::OpenAPI::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;
for (QString t : tags) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::OpenAPI::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;
for (QString t : tags) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
fullPath.append(::OpenAPI::toStringValue(t));
count++;
}
}
}
}
OAIHttpRequestInput input(fullPath, "GET");
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
findPetsByTagsCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit findPetsByTagsErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
QList<OAIPet> empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::findPetsByTagsCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
QList<OAIPet> output;
const QString json(response);
QByteArray array(json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonArray jsonArray = doc.array();
for (QJsonValue obj : jsonArray) {
OAIPet val;
::OpenAPI::fromJsonValue(val, obj);
output.append(val);
}
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit findPetsByTagsFinished(output);
}
/**
* \fn virtual void OAIPetApi::findPetsImageById(const qint64 &petId)
* 'findPetsImageById' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] petId qint64 [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::findPetsImageById(const qint64 &petId, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'findPetsImageById' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * findPetsImageById(petId, this, [&](QRestReply &reply, QString &summary) { if (reply.isSuccess()) ... });
+ * findPetsImageById(petId, this, [&](const QRestReply &reply, const QString &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual findPetsImageByIdWithDataImpl() in derived class.
* The virtual findPetsImageByIdWithDataImpl() is being called by the template
* function.
* @param[in] petId qint64 [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::findPetsImageByIdCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by findPetsImageByIdFinished() or
* being returned as a callback parameter of findPetsImageById() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::findPetsImageByIdWithDataImpl(const qint64 &petId, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the findPetsImageById() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking findPetsImageById() operation calls.
* @param[in] petId qint64 [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::findPetsImageByIdWithDataImpl(const qint64 &petId, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["findPetsImageById"][m_serverIndices.value("findPetsImageById")].serverUrl();
QString fullPath = "/pet/findPetsImageById";
m_networkFactory->setBaseUrl(serverUrl);
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
queryStyle = "form";
if (queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
{
if (fullPath.indexOf("?") > 0)
fullPath.append(queryPrefix);
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("petId") + querySuffix + QUrl::toPercentEncoding(::OpenAPI::toStringValue(petId)));
}
OAIHttpRequestInput input(fullPath, "GET");
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
findPetsImageByIdCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit findPetsImageByIdErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
QString empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::findPetsImageByIdCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
QString output;
::OpenAPI::fromStringValue(response, output);
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit findPetsImageByIdFinished(output);
}
/**
* \fn virtual void OAIPetApi::getJsonFile(const qint64 &petId)
* 'getJsonFile' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] petId qint64 [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::getJsonFile(const qint64 &petId, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'getJsonFile' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * getJsonFile(petId, this, [&](QRestReply &reply, OAIHttpFileElement &summary) { if (reply.isSuccess()) ... });
+ * getJsonFile(petId, this, [&](const QRestReply &reply, const OAIHttpFileElement &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual getJsonFileWithDataImpl() in derived class.
* The virtual getJsonFileWithDataImpl() is being called by the template
* function.
* @param[in] petId qint64 [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::getJsonFileCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by getJsonFileFinished() or
* being returned as a callback parameter of getJsonFile() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::getJsonFileWithDataImpl(const qint64 &petId, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the getJsonFile() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking getJsonFile() operation calls.
* @param[in] petId qint64 [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::getJsonFileWithDataImpl(const qint64 &petId, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["getJsonFile"][m_serverIndices.value("getJsonFile")].serverUrl();
QString fullPath = "/pet/{petId}/uploadImage";
m_networkFactory->setBaseUrl(serverUrl);
QString petIdPathParam("{");
petIdPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "simple";
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(petIdPathParam, QUrl::toPercentEncoding(paramString + ::OpenAPI::toStringValue(petId)));
OAIHttpRequestInput input(fullPath, "GET");
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
getJsonFileCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit getJsonFileErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
OAIHttpFileElement empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::getJsonFileCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
QMap<QString, OAIHttpFileElement> responseFiles;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory, &responseFiles);
OAIHttpFileElement output = OAIHttpRequestWorker::getHttpFileElement(responseFiles);
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit getJsonFileFinished(output);
}
/**
* \fn virtual void OAIPetApi::getPetById(const qint64 &petId)
* 'getPetById' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] petId qint64 [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::getPetById(const qint64 &petId, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'getPetById' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * getPetById(petId, this, [&](QRestReply &reply, OAIPet &summary) { if (reply.isSuccess()) ... });
+ * getPetById(petId, this, [&](const QRestReply &reply, const OAIPet &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual getPetByIdWithDataImpl() in derived class.
* The virtual getPetByIdWithDataImpl() is being called by the template
* function.
* @param[in] petId qint64 [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::getPetByIdCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by getPetByIdFinished() or
* being returned as a callback parameter of getPetById() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::getPetByIdWithDataImpl(const qint64 &petId, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the getPetById() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking getPetById() operation calls.
* @param[in] petId qint64 [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::getPetByIdWithDataImpl(const qint64 &petId, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["getPetById"][m_serverIndices.value("getPetById")].serverUrl();
QString fullPath = "/pet/{petId}";
m_networkFactory->setBaseUrl(serverUrl);
if (m_apiKeys.contains("api_key"_L1)) {
setHeader("api_key"_L1, QAnyStringView(m_apiKeys.find("api_key"_L1).value()));
}
QString petIdPathParam("{");
petIdPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "simple";
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(petIdPathParam, QUrl::toPercentEncoding(paramString + ::OpenAPI::toStringValue(petId)));
OAIHttpRequestInput input(fullPath, "GET");
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
getPetByIdCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit getPetByIdErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
OAIPet empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::getPetByIdCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
OAIPet output(response);
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit getPetByIdFinished(output);
}
/**
* \fn virtual void OAIPetApi::updatePet(const OAIPet &oAIPet)
* 'updatePet' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] oAIPet OAIPet [required]
*/
/**
* \fn template < Functor, > void OAIPetApi::updatePet(const OAIPet &oAIPet, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'updatePet' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * updatePet(oAIPet, this, [&](QRestReply &reply, OAIPet &summary) { if (reply.isSuccess()) ... });
+ * updatePet(oAIPet, this, [&](const QRestReply &reply, const OAIPet &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual updatePetWithDataImpl() in derived class.
* The virtual updatePetWithDataImpl() is being called by the template
* function.
* @param[in] oAIPet OAIPet [required]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::updatePetCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by updatePetFinished() or
* being returned as a callback parameter of updatePet() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::updatePetWithDataImpl(const OAIPet &oAIPet, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the updatePet() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking updatePet() operation calls.
* @param[in] oAIPet OAIPet [required]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::updatePetWithDataImpl(const OAIPet &oAIPet, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["updatePet"][m_serverIndices.value("updatePet")].serverUrl();
QString fullPath = "/pet";
m_networkFactory->setBaseUrl(serverUrl);
if (m_apiKeys.contains("api_key_query")) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("api_key_query=").append(m_apiKeys.find("api_key_query").value());
}
OAIHttpRequestInput input(fullPath, "PUT");
{
QByteArray output = oAIPet.asJson().toUtf8();
input.m_requestBody.append(output);
}
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
updatePetCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit updatePetErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
OAIPet empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::updatePetCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
OAIPet output(response);
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit updatePetFinished(output);
}
/**
* \fn virtual void OAIPetApi::updatePetWithForm(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &name = ::OpenAPI::OptionalParam<QString>(), const ::OpenAPI::OptionalParam<QString> &status = ::OpenAPI::OptionalParam<QString>())
* 'updatePetWithForm' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] petId qint64 [required]
* @param[in] name QString [optional]
* @param[in] status QString [optional]
*/
/**
* \fn template < Functor, > void OAIPetApi::updatePetWithForm(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &name = ::OpenAPI::OptionalParam<QString>(), const ::OpenAPI::OptionalParam<QString> &status = ::OpenAPI::OptionalParam<QString>(), const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'updatePetWithForm' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * updatePetWithForm(petId, name, status, this, [&](QRestReply &reply) { if (reply.isSuccess()) ... });
+ * updatePetWithForm(petId, name, status, this, [&](const QRestReply &reply) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual updatePetWithFormWithDataImpl() in derived class.
* The virtual updatePetWithFormWithDataImpl() is being called by the template
* function.
* @param[in] petId qint64 [required]
* @param[in] name QString [optional]
* @param[in] status QString [optional]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::updatePetWithFormCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by updatePetWithFormFinished() or
* being returned as a callback parameter of updatePetWithForm() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::updatePetWithFormWithDataImpl(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &name, const ::OpenAPI::OptionalParam<QString> &status, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the updatePetWithForm() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking updatePetWithForm() operation calls.
* @param[in] petId qint64 [required]
* @param[in] name QString [optional]
* @param[in] status QString [optional]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::updatePetWithFormWithDataImpl(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &name, const ::OpenAPI::OptionalParam<QString> &status, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["updatePetWithForm"][m_serverIndices.value("updatePetWithForm")].serverUrl();
QString fullPath = "/pet/{petId}";
m_networkFactory->setBaseUrl(serverUrl);
QString petIdPathParam("{");
petIdPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "simple";
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(petIdPathParam, QUrl::toPercentEncoding(paramString + ::OpenAPI::toStringValue(petId)));
OAIHttpRequestInput input(fullPath, "POST");
if (name.hasValue()) {
input.addVar("name", ::OpenAPI::toStringValue(name.value()));
}
if (status.hasValue()) {
input.addVar("status", ::OpenAPI::toStringValue(status.value()));
}
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
updatePetWithFormCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit updatePetWithFormErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::updatePetWithFormCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply) };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit updatePetWithFormFinished();
}
/**
* \fn virtual void OAIPetApi::uploadFile(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &additionalMetadata = ::OpenAPI::OptionalParam<QString>(), const ::OpenAPI::OptionalParam<OAIHttpFileElement> &file = ::OpenAPI::OptionalParam<OAIHttpFileElement>())
* 'uploadFile' operation sends the request to a server.
* The request parameters are defined by a specification file.
* @param[in] petId qint64 [required]
* @param[in] additionalMetadata QString [optional]
* @param[in] file OAIHttpFileElement [optional]
*/
/**
* \fn template < Functor, > void OAIPetApi::uploadFile(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &additionalMetadata = ::OpenAPI::OptionalParam<QString>(), const ::OpenAPI::OptionalParam<OAIHttpFileElement> &file = ::OpenAPI::OptionalParam<OAIHttpFileElement>(), const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
* 'uploadFile' operation sends the request to a server.
* The request parameters are defined by a specification file.
*
* \attention Use the operation with following parameters in the callback:
* \code {c++}
- * uploadFile(petId, additionalMetadata, file, this, [&](QRestReply &reply, OAIApiResponse &summary) { if (reply.isSuccess()) ... });
+ * uploadFile(petId, additionalMetadata, file, this, [&](const QRestReply &reply, const OAIApiResponse &summary) { if (reply.isSuccess()) ... });
* \endcode
* \note The template function can not be virtual in C++17.
* If you want to use 'makeOperationsVirtual' option for mocking API,
* please override virtual uploadFileWithDataImpl() in derived class.
* The virtual uploadFileWithDataImpl() is being called by the template
* function.
* @param[in] petId qint64 [required]
* @param[in] additionalMetadata QString [optional]
* @param[in] file OAIHttpFileElement [optional]
* @param[in] context const ContextTypeForFunctor< Functor > * [optional]
* @param[in] callback Functor && [optional]
*/
/**
* \fn void OAIPetApi::uploadFileCallback(const QRestReply &reply)
* Processes a \a reply response from a server.
* The result of processed data is emitted by uploadFileFinished() or
* being returned as a callback parameter of uploadFile() request.
* @param[in] reply const QRestReply &
*/
/**
* \fn virtual void OAIPetApi::uploadFileWithDataImpl(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &additionalMetadata, const ::OpenAPI::OptionalParam<OAIHttpFileElement> &file, const QObject *context, QtPrivate::QSlotObjectBase *slot)
* Implements the uploadFile() operation request.
* \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
* and can be overloaded for mocking uploadFile() operation calls.
* @param[in] petId qint64 [required]
* @param[in] additionalMetadata QString [optional]
* @param[in] file OAIHttpFileElement [optional]
* @param[in] context const QObject * [optional]
* @param[in] slot QtPrivate::QSlotObjectBase * [optional]
*/
void OAIPetApi::uploadFileWithDataImpl(const qint64 &petId, const ::OpenAPI::OptionalParam<QString> &additionalMetadata, const ::OpenAPI::OptionalParam<OAIHttpFileElement> &file, const QObject *context, QtPrivate::QSlotObjectBase *slot)
{
const QUrl serverUrl = m_serverConfigs["uploadFile"][m_serverIndices.value("uploadFile")].serverUrl();
QString fullPath = "/pet/{petId}/uploadImage";
m_networkFactory->setBaseUrl(serverUrl);
QString petIdPathParam("{");
petIdPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "simple";
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(petIdPathParam, QUrl::toPercentEncoding(paramString + ::OpenAPI::toStringValue(petId)));
OAIHttpRequestInput input(fullPath, "POST");
if (additionalMetadata.hasValue()) {
input.addVar("additionalMetadata", ::OpenAPI::toStringValue(additionalMetadata.value()));
}
if (file.hasValue()) {
input.addFile("file", file.value().m_localFilename, file.value().m_requestFilename, file.value().m_mimeType);
}
QByteArray requestContent;
QNetworkRequest request
= OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
QNetworkReply *reply = execute(input, request, requestContent);
if (reply != nullptr) {
reply->setParent(this);
m_callerData.insert(reply, OAICallerInfo{context, slot});
connect(reply, &QNetworkReply::finished, this, [this, reply] {
uploadFileCallback(QRestReply(reply));
});
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
if (reply) {
emit uploadFileErrorOccurred(reply->error(), reply->errorString());
OAICallerInfo callerInfo = m_callerData.take(reply);
if (callerInfo.slot) {
OAIApiResponse empty;
QRestReply restRepl(reply);
void *argv[] = { nullptr, &restRepl, &empty };
QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
}
});
}
}
void OAIPetApi::uploadFileCallback(const QRestReply &reply)
{
auto netReply = reply.networkReply();
if (netReply)
disconnect(netReply, nullptr, nullptr, nullptr);
if (!reply.isSuccess())
return;
const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
OAIApiResponse output(response);
// Check if callback is provided
OAICallerInfo callerInfo = m_callerData.take(netReply);
if (callerInfo.slot) {
void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
QObject *context = callerInfo.contextObject
? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
callerInfo.slot->call(context, argv);
}
emit uploadFileFinished(output);
}
} // namespace OpenAPI