Revision control
+ /**
+ * Client with 'Skip-All' option Test
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * Do not edit the class manually.
+ */
+
+ #include "QtOAIClient2TestApi.h"
+ #include "QtOAIServerConfiguration.h"
+
+ #include <QtCore/qanystringview.h>
+ #include <QtCore/qjsonarray.h>
+ #include <QtCore/qjsondocument.h>
+ #include <QtNetwork/qhttpmultipart.h>
+ #include <QtNetwork/qnetworkaccessmanager.h>
+ #include <QtNetwork/qnetworkreply.h>
+ #include <QtNetwork/qnetworkrequestfactory.h>
+ #include <QtNetwork/qrestaccessmanager.h>
+
+ using namespace Qt::StringLiterals;
+
+ namespace QtOpenAPI {
+
+ QtOAIClient2TestApi::QtOAIClient2TestApi(QObject *parent)
+ : QtOAIBaseApi(parent)
+ {
+ initializeServerConfigs();
+ }
+
+ QtOAIClient2TestApi::~QtOAIClient2TestApi()
+ {
+ }
+
+ void QtOAIClient2TestApi::initializeServerConfigs()
+ {
+ //Default server
+ QList<QtOAIServerConfiguration> defaultConf = QList<QtOAIServerConfiguration>();
+ //varying endpoint server
+ defaultConf.append(QtOAIServerConfiguration(
+ QUrl("http://127.0.0.1:10205/v2"),
+ "No description provided",
+ QMap<QString, QtOAIServerVariable>()));
+ m_serverConfigs.insert("simpleExplodeInt", defaultConf);
+ m_serverIndices.insert("simpleExplodeInt", 0);
+ }
+
+ /**
+ * \fn virtual void QtOAIClient2TestApi::simpleExplodeInt(const qint64 &intParameter)
+ * 'simpleExplodeInt' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+
+ * @param[in] intParameter qint64 [required]
+ */
+
+ /**
+ * \fn template < Functor, > void QtOAIClient2TestApi::simpleExplodeInt(const qint64 &intParameter, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
+ * 'simpleExplodeInt' 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++}
+ * simpleExplodeInt(intParameter, 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 simpleExplodeIntWithDataImpl() in derived class.
+ * The virtual simpleExplodeIntWithDataImpl() is being called by the template
+ * function.
+
+ * @param[in] intParameter qint64 [required]
+ * @param[in] context const ContextTypeForFunctor< Functor > * [optional]
+ * @param[in] callback Functor && [optional]
+ */
+
+ /**
+ * \fn void QtOAIClient2TestApi::simpleExplodeIntCallback(const QRestReply &reply)
+ * Processes a \a reply response from a server.
+ * The result of processed data is emitted by simpleExplodeIntFinished() or
+ * being returned as a callback parameter of simpleExplodeInt() request.
+ * @param[in] reply const QRestReply &
+ */
+
+ /**
+ * \fn virtual void QtOAIClient2TestApi::simpleExplodeIntWithDataImpl(const qint64 &intParameter, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ * Implements the simpleExplodeInt() operation request.
+ * \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
+ * and can be overloaded for mocking simpleExplodeInt() operation calls.
+
+ * @param[in] intParameter qint64 [required]
+ * @param[in] context const QObject * [optional]
+ * @param[in] slot QtPrivate::QSlotObjectBase * [optional]
+ */
+ void QtOAIClient2TestApi::simpleExplodeIntWithDataImpl(const qint64 &intParameter, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ {
+ const QUrl serverUrl = m_serverConfigs["simpleExplodeInt"][m_serverIndices.value("simpleExplodeInt")].serverUrl();
+ QString fullPath = "/path/int/simple-explode/{intParameter}";
+ m_networkFactory->setBaseUrl(serverUrl);
+ {
+ QString intParameterPathParam = QString("{%1}").arg("intParameter");
+
+ SerializationFlags flags;
+ flags.setFlag(SerializationFlag::Object, false || false);
+ flags.setFlag(SerializationFlag::NeedPercentEncoding, true);
+ flags.setFlag(SerializationFlag::Explode, true);
+
+ SerializationOptions opts;
+ opts.style = "simple"_L1.isEmpty() ? "simple"_L1 : "simple"_L1;
+ opts.prefix = getParamStylePrefix(opts.style);
+ opts.delimiter = getParamStyleDelimiter(opts.style, flags);
+ opts.assignOperator = getParamStyleAssignOperator(opts.style, flags);
+ opts.suffix = getParamStyleSuffix(opts.style, QUrl::toPercentEncoding(u"intParameter"_s), flags);
+ opts.flags = flags;
+ QString paramString = opts.prefix + opts.suffix;
+ paramString += QUrl::toPercentEncoding(::QtOpenAPI::toStringValue(intParameter));
+ // In case style=matrix and paramString is empty due to any reasons,
+ // we serialize it like undefined value and delete '='.
+ // Described here: https://spec.openapis.org/oas/v3.1.1.html#style-values
+ if ((paramString == opts.prefix + opts.suffix) && QString("simple") == "matrix"_L1)
+ paramString.chop(1);
+ fullPath.replace(intParameterPathParam, paramString);
+ }
+
+ // set m_testOperationPath for serialization tests
+ m_testOperationPath = fullPath;
+ QtOAIHttpRequestInput input(fullPath, "GET");
+ QNetworkRequest request
+ = QtOAIHttpRequestWorker::getNetworkRequest(input, m_requestContent, m_networkFactory,
+ m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
+ QNetworkReply *reply = execute(input, request, m_requestContent);
+ if (reply != nullptr) {
+ reply->setParent(this);
+ m_callerData.insert(reply, QtOAICallerInfo{context, slot});
+ connect(reply, &QNetworkReply::finished, this, [this, reply] {
+ simpleExplodeIntCallback(QRestReply(reply));
+ });
+ connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
+ if (reply) {
+ emit simpleExplodeIntErrorOccurred(reply->error(), reply->errorString());
+ QtOAICallerInfo 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 QtOAIClient2TestApi::simpleExplodeIntCallback(const QRestReply &reply)
+ {
+ auto netReply = reply.networkReply();
+ if (netReply)
+ netReply->disconnect(this);
+ if (!reply.isSuccess())
+ return;
+
+ const QByteArray response = QtOAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
+ QString output;
+ const bool ok = ::QtOpenAPI::fromByteArray(response, output);
+ if (!ok)
+ qWarning("%s: Failed to convert the response to QString.", Q_FUNC_INFO);
+ // Check if callback is provided
+ QtOAICallerInfo 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 simpleExplodeIntFinished(output);
+ }
+
+ } // namespace QtOpenAPI