Thi b7d079b7e3
[Cpp][Qt][client] Fixed issue with unique items in OpenAPI schema (#11954)
* [cpp-qt-client] Fix CMakeLists.txt

Changed: Always add Qt5::Gui to build
Added: find_package for OpenSSL (if not Apple)

* Revert "[cpp-qt-client] Fix CMakeLists.txt"

This reverts commit db5c3423b92410115f4c3d5f8b6ca0cabb58f9f6.

* Revert "Revert "[cpp-qt-client] Fix CMakeLists.txt""

This reverts commit c4f055f3cdf666b3ce265fa14e297c3b11d803d9.

* [Cpp][Qt][client] Fixed unique items in OpenAPI schema

Added equal operator for schema objects
Added qhash Operator

in api template
depending on unique items
output.insert(val) -- QSet (unique items)
or
ouput.appen(val) -- QList (not unique items)

* Added petstore with unique items to tests schemas, added config for [cpp][qt] and this schema

* Run ./bin/generate-samples.sh bin/configs/cpp-qt-client* for new schemas and tests

* Update bin/configs/cpp-qt-client-petstore-unique.yaml

Co-authored-by: Martin Delille <martin@delille.org>

* Update bin/configs/cpp-qt-client-petstore-unique.yaml

Co-authored-by: Martin Delille <martin@delille.org>

* Fixxed typo in name of spec file, too.

* Moved petstore_plus_unique.json to correct directory  (2_0 -> 3_0 )

moved open api specification
rerun generate samples

* Deleted obsolete samples output

* Removed obsolete files   (unique items petstore yaml definition and samples)

* Updated samples output for cpp-qt

Co-authored-by: Martin Delille <martin@delille.org>
2022-05-08 15:14:41 +08:00

195 lines
8.3 KiB
C++

/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#ifndef PFX_PFXPetApi_H
#define PFX_PFXPetApi_H
#include "PFXHelpers.h"
#include "PFXHttpRequest.h"
#include "PFXServerConfiguration.h"
#include "PFXOauth.h"
#include "PFXApiResponse.h"
#include "PFXHttpFileElement.h"
#include "PFXPet.h"
#include <QSet>
#include <QString>
#include <QObject>
#include <QByteArray>
#include <QStringList>
#include <QList>
#include <QNetworkAccessManager>
namespace test_namespace {
class PFXPetApi : public QObject {
Q_OBJECT
public:
PFXPetApi(const int timeOut = 0);
~PFXPetApi();
void initializeServerConfigs();
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
void setServerIndex(const QString &operation, int serverIndex);
void setApiKey(const QString &apiKeyName, const QString &apiKey);
void setBearerToken(const QString &token);
void setUsername(const QString &username);
void setPassword(const QString &password);
void setTimeOut(const int timeOut);
void setWorkingDirectory(const QString &path);
void setNetworkAccessManager(QNetworkAccessManager* manager);
int addServerConfiguration(const QString &operation, const QUrl &url, const QString &description = "", const QMap<QString, PFXServerVariable> &variables = QMap<QString, PFXServerVariable>());
void setNewServerForAllOperations(const QUrl &url, const QString &description = "", const QMap<QString, PFXServerVariable> &variables = QMap<QString, PFXServerVariable>());
void setNewServer(const QString &operation, const QUrl &url, const QString &description = "", const QMap<QString, PFXServerVariable> &variables = QMap<QString, PFXServerVariable>());
void addHeaders(const QString &key, const QString &value);
void enableRequestCompression();
void enableResponseCompression();
void abortRequests();
QString getParamStylePrefix(const QString &style);
QString getParamStyleSuffix(const QString &style);
QString getParamStyleDelimiter(const QString &style, const QString &name, bool isExplode);
/**
* @param[in] pfx_pet PFXPet [required]
*/
void addPet(const PFXPet &pfx_pet);
void allPets();
/**
* @param[in] pet_id qint64 [required]
* @param[in] api_key QString [optional]
*/
void deletePet(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &api_key = ::test_namespace::OptionalParam<QString>());
/**
* @param[in] status QList<QString> [required]
*/
void findPetsByStatus(const QList<QString> &status);
/**
* @param[in] tags QList<QString> [required]
*/
Q_DECL_DEPRECATED void findPetsByTags(const QList<QString> &tags);
/**
* @param[in] pet_id qint64 [required]
*/
void getPetById(const qint64 &pet_id);
/**
* @param[in] pfx_pet PFXPet [required]
*/
void updatePet(const PFXPet &pfx_pet);
/**
* @param[in] pet_id qint64 [required]
* @param[in] name QString [optional]
* @param[in] status QString [optional]
*/
void updatePetWithForm(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &name = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<QString> &status = ::test_namespace::OptionalParam<QString>());
/**
* @param[in] pet_id qint64 [required]
* @param[in] additional_metadata QString [optional]
* @param[in] file PFXHttpFileElement [optional]
*/
void uploadFile(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &additional_metadata = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<PFXHttpFileElement> &file = ::test_namespace::OptionalParam<PFXHttpFileElement>());
private:
QMap<QString,int> _serverIndices;
QMap<QString,QList<PFXServerConfiguration>> _serverConfigs;
QMap<QString, QString> _apiKeys;
QString _bearerToken;
QString _username;
QString _password;
int _timeOut;
QString _workingDirectory;
QNetworkAccessManager* _manager;
QMap<QString, QString> _defaultHeaders;
bool _isResponseCompressionEnabled;
bool _isRequestCompressionEnabled;
PFXHttpRequestInput _latestInput;
PFXHttpRequestWorker *_latestWorker;
QStringList _latestScope;
OauthCode _authFlow;
OauthImplicit _implicitFlow;
OauthCredentials _credentialFlow;
OauthPassword _passwordFlow;
int _OauthMethod = 0;
void addPetCallback(PFXHttpRequestWorker *worker);
void allPetsCallback(PFXHttpRequestWorker *worker);
void deletePetCallback(PFXHttpRequestWorker *worker);
void findPetsByStatusCallback(PFXHttpRequestWorker *worker);
void findPetsByTagsCallback(PFXHttpRequestWorker *worker);
void getPetByIdCallback(PFXHttpRequestWorker *worker);
void updatePetCallback(PFXHttpRequestWorker *worker);
void updatePetWithFormCallback(PFXHttpRequestWorker *worker);
void uploadFileCallback(PFXHttpRequestWorker *worker);
signals:
void addPetSignal();
void allPetsSignal(QSet<PFXPet> summary);
void deletePetSignal();
void findPetsByStatusSignal(QList<PFXPet> summary);
void findPetsByTagsSignal(QList<PFXPet> summary);
void getPetByIdSignal(PFXPet summary);
void updatePetSignal();
void updatePetWithFormSignal();
void uploadFileSignal(PFXApiResponse summary);
void addPetSignalFull(PFXHttpRequestWorker *worker);
void allPetsSignalFull(PFXHttpRequestWorker *worker, QSet<PFXPet> summary);
void deletePetSignalFull(PFXHttpRequestWorker *worker);
void findPetsByStatusSignalFull(PFXHttpRequestWorker *worker, QList<PFXPet> summary);
void findPetsByTagsSignalFull(PFXHttpRequestWorker *worker, QList<PFXPet> summary);
void getPetByIdSignalFull(PFXHttpRequestWorker *worker, PFXPet summary);
void updatePetSignalFull(PFXHttpRequestWorker *worker);
void updatePetWithFormSignalFull(PFXHttpRequestWorker *worker);
void uploadFileSignalFull(PFXHttpRequestWorker *worker, PFXApiResponse summary);
void addPetSignalE(QNetworkReply::NetworkError error_type, QString error_str);
void allPetsSignalE(QSet<PFXPet> summary, QNetworkReply::NetworkError error_type, QString error_str);
void deletePetSignalE(QNetworkReply::NetworkError error_type, QString error_str);
void findPetsByStatusSignalE(QList<PFXPet> summary, QNetworkReply::NetworkError error_type, QString error_str);
void findPetsByTagsSignalE(QList<PFXPet> summary, QNetworkReply::NetworkError error_type, QString error_str);
void getPetByIdSignalE(PFXPet summary, QNetworkReply::NetworkError error_type, QString error_str);
void updatePetSignalE(QNetworkReply::NetworkError error_type, QString error_str);
void updatePetWithFormSignalE(QNetworkReply::NetworkError error_type, QString error_str);
void uploadFileSignalE(PFXApiResponse summary, QNetworkReply::NetworkError error_type, QString error_str);
void addPetSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void allPetsSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void deletePetSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void findPetsByStatusSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void findPetsByTagsSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void getPetByIdSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void updatePetSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void updatePetWithFormSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void uploadFileSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void abortRequestsSignal();
void allPendingRequestsCompleted();
public slots:
void tokenAvailable();
};
} // namespace test_namespace
#endif