Revision control

+ /**
+ * Client with 'QtOpenAPICommon' option Test
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * Do not edit the class manually.
+ */
+
+ #include "QtOAIClient1TestApi.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 {
+
+ QtOAIClient1TestApi::QtOAIClient1TestApi(QObject *parent)
+ : QtOAIBaseApi(parent)
+ {
+ initializeServerConfigs();
+ }
+
+ QtOAIClient1TestApi::~QtOAIClient1TestApi()
+ {
+ }
+
+ void QtOAIClient1TestApi::initializeServerConfigs()
+ {
+ //Default server
+ QList<QtOAIServerConfiguration> defaultConf = QList<QtOAIServerConfiguration>();
+ //varying endpoint server
+ defaultConf.append(QtOAIServerConfiguration(
+ "No description provided",
+ QMap<QString, QtOAIServerVariable>()));
+ m_serverConfigs.insert("simpleExplodeString", defaultConf);
+ m_serverIndices.insert("simpleExplodeString", 0);
+ }
+
+ /**
+ * \fn virtual void QtOAIClient1TestApi::simpleExplodeString(const QString &stringParameter)
+ * 'simpleExplodeString' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+
+ * @param[in] stringParameter QString [required]
+ */
+
+ /**
+ * \fn template < Functor, > void QtOAIClient1TestApi::simpleExplodeString(const QString &stringParameter, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
+ * 'simpleExplodeString' 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++}
+ * simpleExplodeString(stringParameter, 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 simpleExplodeStringWithDataImpl() in derived class.
+ * The virtual simpleExplodeStringWithDataImpl() is being called by the template
+ * function.
+
+ * @param[in] stringParameter QString [required]
+ * @param[in] context const ContextTypeForFunctor< Functor > * [optional]
+ * @param[in] callback Functor && [optional]
+ */
+
+ /**
+ * \fn void QtOAIClient1TestApi::simpleExplodeStringCallback(const QRestReply &reply)
+ * Processes a \a reply response from a server.
+ * The result of processed data is emitted by simpleExplodeStringFinished() or
+ * being returned as a callback parameter of simpleExplodeString() request.
+ * @param[in] reply const QRestReply &
+ */
+
+ /**
+ * \fn virtual void QtOAIClient1TestApi::simpleExplodeStringWithDataImpl(const QString &stringParameter, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ * Implements the simpleExplodeString() operation request.
+ * \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
+ * and can be overloaded for mocking simpleExplodeString() operation calls.
+
+ * @param[in] stringParameter QString [required]
+ * @param[in] context const QObject * [optional]
+ * @param[in] slot QtPrivate::QSlotObjectBase * [optional]
+ */
+ void QtOAIClient1TestApi::simpleExplodeStringWithDataImpl(const QString &stringParameter, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ {
+ const QUrl serverUrl = m_serverConfigs["simpleExplodeString"][m_serverIndices.value("simpleExplodeString")].serverUrl();
+ QString fullPath = "/path/string/simple-explode/{stringParameter}";
+ m_networkFactory->setBaseUrl(serverUrl);
+ {
+ QString stringParameterPathParam = QString("{%1}").arg("stringParameter");
+
+ 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"stringParameter"_s), flags);
+ opts.flags = flags;
+ QString paramString = opts.prefix + opts.suffix;
+ paramString += QUrl::toPercentEncoding(::QtOpenAPI::toStringValue(stringParameter));
+ // In case style=matrix and paramString is empty due to any reasons,
+ // we serialize it like undefined value and delete '='.
+ if ((paramString == opts.prefix + opts.suffix) && QString("simple") == "matrix"_L1)
+ paramString.chop(1);
+ fullPath.replace(stringParameterPathParam, 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] {
+ simpleExplodeStringCallback(QRestReply(reply));
+ });
+ connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
+ if (reply) {
+ emit simpleExplodeStringErrorOccurred(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 QtOAIClient1TestApi::simpleExplodeStringCallback(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 simpleExplodeStringFinished(output);
+ }
+
+ } // namespace QtOpenAPI