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

74 lines
1.6 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_OBJECT_H
#define PFX_OBJECT_H
#include <QJsonDocument>
#include <QJsonObject>
#include <QMetaType>
namespace test_namespace {
class PFXObject {
public:
PFXObject() {}
PFXObject(QString jsonString) {
fromJson(jsonString);
}
virtual ~PFXObject() {}
virtual QJsonObject asJsonObject() const {
return jObj;
}
virtual QString asJson() const {
QJsonDocument doc(jObj);
return doc.toJson(QJsonDocument::Compact);
}
virtual void fromJson(QString jsonString) {
QJsonDocument doc = QJsonDocument::fromJson(jsonString.toUtf8());
jObj = doc.object();
}
virtual void fromJsonObject(QJsonObject json) {
jObj = json;
}
virtual bool isSet() const {
return false;
}
virtual bool isValid() const {
return true;
}
private:
QJsonObject jObj;
};
inline bool operator==(const PFXObject& left, const PFXObject& right){
return (left.asJsonObject() == right.asJsonObject());
}
inline uint qHash(const PFXObject& obj, uint seed = 0) noexcept{
return qHash(obj.asJsonObject(), seed);
}
} // namespace test_namespace
Q_DECLARE_METATYPE(test_namespace::PFXObject)
#endif // PFX_OBJECT_H