forked from loafle/openapi-generator-original
[C++] [Qt5] Add enum support for client and server (#2339)
* Add enum support to Qt5 client and server * Correct model name prefix * Remove tabs * Correct wrong filename when prefix used
This commit is contained in:
parent
0bc06f8d4d
commit
3bb4edf865
@ -5,6 +5,7 @@ import io.swagger.v3.oas.models.media.Schema;
|
|||||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.CodegenConfig;
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
|
import org.openapitools.codegen.CodegenModel;
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
import org.openapitools.codegen.CodegenOperation;
|
||||||
import org.openapitools.codegen.CodegenParameter;
|
import org.openapitools.codegen.CodegenParameter;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
@ -280,7 +281,19 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||||
|
|
||||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel> ();
|
||||||
|
for(Object moObj : allModels) {
|
||||||
|
CodegenModel mo = ((Map<String, CodegenModel>) moObj).get("model");
|
||||||
|
if(mo.isEnum) {
|
||||||
|
codegenModels.put(mo.classname, mo);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (CodegenOperation operation : operations) {
|
for (CodegenOperation operation : operations) {
|
||||||
|
if(operation.returnType != null) {
|
||||||
|
if(codegenModels.containsKey(operation.returnType)){
|
||||||
|
operation.vendorExtensions.put("returnsEnum", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Check all return parameter baseType if there is a necessity to include, include it if not
|
// Check all return parameter baseType if there is a necessity to include, include it if not
|
||||||
// already done
|
// already done
|
||||||
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||||
@ -316,6 +329,21 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
return postProcessModelsEnum(objs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumValue(String value, String datatype) {
|
||||||
|
return escapeText(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDataTypeString(String dataType) {
|
||||||
|
return "QString".equals(dataType);
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, String> createMapping(String key, String value) {
|
private Map<String, String> createMapping(String key, String value) {
|
||||||
Map<String, String> customImport = new HashMap<String, String>();
|
Map<String, String> customImport = new HashMap<String, String>();
|
||||||
customImport.put(key, toModelImport(value));
|
customImport.put(key, toModelImport(value));
|
||||||
|
@ -75,6 +75,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
|
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
|
||||||
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
|
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
|
||||||
if (optionalProjectFileFlag) {
|
if (optionalProjectFileFlag) {
|
||||||
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
|
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
|
||||||
}
|
}
|
||||||
@ -100,6 +101,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
|
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
|
||||||
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
|
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
|
||||||
|
|
||||||
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
|
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
|
||||||
typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
|
typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
|
||||||
|
@ -83,6 +83,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
|
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
|
||||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
|
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, PREFIX + "Enum.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
|
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
|
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
|
||||||
|
|
||||||
@ -106,6 +107,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.h"));
|
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.h"));
|
||||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
|
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Enum.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
|
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
|
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ HEADERS += \
|
|||||||
$${PWD}/{{prefix}}Helpers.h \
|
$${PWD}/{{prefix}}Helpers.h \
|
||||||
$${PWD}/{{prefix}}HttpRequest.h \
|
$${PWD}/{{prefix}}HttpRequest.h \
|
||||||
$${PWD}/{{prefix}}Object.h
|
$${PWD}/{{prefix}}Object.h
|
||||||
|
$${PWD}/{{prefix}}Enum.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
# Models
|
# Models
|
||||||
|
57
modules/openapi-generator/src/main/resources/cpp-qt5-client/enum.mustache
vendored
Normal file
57
modules/openapi-generator/src/main/resources/cpp-qt5-client/enum.mustache
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{{>licenseInfo}}
|
||||||
|
#ifndef {{prefix}}_ENUM_H
|
||||||
|
#define {{prefix}}_ENUM_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
{{#cppNamespaceDeclarations}}
|
||||||
|
namespace {{this}} {
|
||||||
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
|
class {{prefix}}Enum {
|
||||||
|
public:
|
||||||
|
{{prefix}}Enum() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{{prefix}}Enum(QString jsonString) {
|
||||||
|
fromJson(jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~{{prefix}}Enum(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QJsonValue asJsonValue() const {
|
||||||
|
return QJsonValue(jstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString asJson() const {
|
||||||
|
return jstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void fromJson(QString jsonString) {
|
||||||
|
jstr = jsonString;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void fromJsonValue(QJsonValue jval) {
|
||||||
|
jstr = jval.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isSet() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isValid() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private :
|
||||||
|
QString jstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
{{#cppNamespaceDeclarations}}
|
||||||
|
}
|
||||||
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
|
#endif // {{prefix}}_ENUM_H
|
@ -1,7 +1,7 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "{{prefix}}Helpers.h"
|
#include "{{prefix}}Helpers.h"
|
||||||
#include "{{prefix}}Object.h"
|
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
@ -55,6 +55,11 @@ toStringValue(const double &value){
|
|||||||
return QString::number(value);
|
return QString::number(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
toStringValue(const {{prefix}}Enum &value){
|
||||||
|
return value.asJson();
|
||||||
|
}
|
||||||
|
|
||||||
QJsonValue
|
QJsonValue
|
||||||
toJsonValue(const QString &value){
|
toJsonValue(const QString &value){
|
||||||
return QJsonValue(value);
|
return QJsonValue(value);
|
||||||
@ -105,6 +110,11 @@ toJsonValue(const {{prefix}}Object &value){
|
|||||||
return value.asJsonObject();
|
return value.asJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonValue
|
||||||
|
toJsonValue(const {{prefix}}Enum &value){
|
||||||
|
return value.asJsonValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fromStringValue(const QString &inStr, QString &value){
|
fromStringValue(const QString &inStr, QString &value){
|
||||||
value.clear();
|
value.clear();
|
||||||
@ -193,6 +203,12 @@ fromStringValue(const QString &inStr, double &value){
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fromStringValue(const QString &inStr, {{prefix}}Enum &value){
|
||||||
|
value.fromJson(inStr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fromJsonValue(QString &value, const QJsonValue &jval){
|
fromJsonValue(QString &value, const QJsonValue &jval){
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
@ -315,6 +331,12 @@ fromJsonValue({{prefix}}Object &value, const QJsonValue &jval){
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval){
|
||||||
|
value.fromJsonValue(jval);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
}
|
}
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "{{prefix}}Object.h"
|
#include "{{prefix}}Object.h"
|
||||||
|
#include "{{prefix}}Enum.h"
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
@ -26,6 +27,7 @@ namespace {{this}} {
|
|||||||
QString toStringValue(const bool &value);
|
QString toStringValue(const bool &value);
|
||||||
QString toStringValue(const float &value);
|
QString toStringValue(const float &value);
|
||||||
QString toStringValue(const double &value);
|
QString toStringValue(const double &value);
|
||||||
|
QString toStringValue(const {{prefix}}Enum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QString toStringValue(const QList<T> &val) {
|
QString toStringValue(const QList<T> &val) {
|
||||||
@ -49,6 +51,7 @@ namespace {{this}} {
|
|||||||
QJsonValue toJsonValue(const float &value);
|
QJsonValue toJsonValue(const float &value);
|
||||||
QJsonValue toJsonValue(const double &value);
|
QJsonValue toJsonValue(const double &value);
|
||||||
QJsonValue toJsonValue(const {{prefix}}Object &value);
|
QJsonValue toJsonValue(const {{prefix}}Object &value);
|
||||||
|
QJsonValue toJsonValue(const {{prefix}}Enum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QJsonValue toJsonValue(const QList<T> &val) {
|
QJsonValue toJsonValue(const QList<T> &val) {
|
||||||
@ -77,6 +80,7 @@ namespace {{this}} {
|
|||||||
bool fromStringValue(const QString &inStr, bool &value);
|
bool fromStringValue(const QString &inStr, bool &value);
|
||||||
bool fromStringValue(const QString &inStr, float &value);
|
bool fromStringValue(const QString &inStr, float &value);
|
||||||
bool fromStringValue(const QString &inStr, double &value);
|
bool fromStringValue(const QString &inStr, double &value);
|
||||||
|
bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||||
@ -110,6 +114,7 @@ namespace {{this}} {
|
|||||||
bool fromJsonValue(float &value, const QJsonValue &jval);
|
bool fromJsonValue(float &value, const QJsonValue &jval);
|
||||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||||
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
|
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
|
||||||
|
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||||
|
@ -28,23 +28,31 @@ namespace {{this}} {
|
|||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::init() {
|
{{classname}}::init() {
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
m_{{name}}_isSet = false;
|
m_{{name}}_isSet = false;
|
||||||
m_{{name}}_isValid = false;
|
m_{{name}}_isValid = false;
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||||
|
m_value_isSet = false;
|
||||||
|
m_value_isValid = false;
|
||||||
|
m_value = e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED;
|
||||||
|
{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::fromJson(QString jsonString) {
|
{{classname}}::fromJson(QString jsonString) {
|
||||||
QByteArray array (jsonString.toStdString().c_str());
|
{{^isEnum}}QByteArray array (jsonString.toStdString().c_str());
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||||
QJsonObject jsonObject = doc.object();
|
QJsonObject jsonObject = doc.object();
|
||||||
this->fromJsonObject(jsonObject);
|
this->fromJsonObject(jsonObject);{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}
|
||||||
|
{{#-first}}if{{/-first}}{{^-first}}else if{{/-first}} ( jsonString.compare({{#isString}}"{{value}}"{{/isString}}{{^isString}}QString::number({{value}}){{/isString}}, Qt::CaseInsensitive) == 0) {
|
||||||
|
m_value = e{{classname}}::{{name}};
|
||||||
|
m_value_isValid = true;
|
||||||
|
}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::fromJsonObject(QJsonObject json) {
|
{{classname}}::fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) {
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{^isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/isContainer}}
|
{{^isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/isContainer}}
|
||||||
{{#isContainer}}{{^items.isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}}
|
{{#isContainer}}{{^items.isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}}
|
||||||
if(json["{{baseName}}"].isArray()){
|
if(json["{{baseName}}"].isArray()){
|
||||||
@ -68,33 +76,45 @@ void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}{{/isMapContainer}}{{/items.isContainer}}{{/isContainer}}
|
}{{/isMapContainer}}{{/items.isContainer}}{{/isContainer}}
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||||
|
{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}fromJson(json.toString());{{/isString}}{{^isString}}m_value = static_cast<e{{classname}}>(json.toInt());{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
{{classname}}::asJson () const {
|
{{classname}}::asJson () const {
|
||||||
QJsonObject obj = this->asJsonObject();
|
{{^isEnum}}QJsonObject obj = this->asJsonObject();
|
||||||
QJsonDocument doc(obj);
|
QJsonDocument doc(obj);
|
||||||
QByteArray bytes = doc.toJson();
|
QByteArray bytes = doc.toJson();
|
||||||
return QString(bytes);
|
return QString(bytes);{{/isEnum}}{{#isEnum}}
|
||||||
|
QString val;
|
||||||
|
{{#allowableValues}}
|
||||||
|
switch (m_value){
|
||||||
|
{{#enumVars}}
|
||||||
|
case e{{classname}}::{{name}}:
|
||||||
|
val = {{#isString}}"{{value}}"{{/isString}}{{^isString}}QString::number({{value}}){{/isString}};
|
||||||
|
break;{{#-last}}
|
||||||
|
default:
|
||||||
|
break;{{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
}{{/allowableValues}}
|
||||||
|
return val;{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject
|
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}
|
||||||
{{classname}}::asJsonObject() const {
|
{{classname}}::asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const {
|
||||||
QJsonObject obj;
|
{{^isEnum}}QJsonObject obj;{{#vars}}
|
||||||
{{#vars}}
|
|
||||||
{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
|
{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
|
||||||
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
|
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
|
||||||
}{{/isContainer}}{{#isContainer}}
|
}{{/isContainer}}{{#isContainer}}
|
||||||
if({{name}}.size() > 0){
|
if({{name}}.size() > 0){
|
||||||
{{^items.isContainer}}obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));{{/items.isContainer}}{{#items.isContainer}}
|
{{^items.isContainer}}obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));{{/items.isContainer}}{{#items.isContainer}}
|
||||||
obj.insert(QString("{{baseName}}"), toJsonValue({{name}}));{{/items.isContainer}}
|
obj.insert(QString("{{baseName}}"), toJsonValue({{name}}));{{/items.isContainer}}
|
||||||
} {{/isContainer}}
|
} {{/isContainer}}{{/vars}}
|
||||||
{{/vars}}
|
return obj;{{/isEnum}}{{#isEnum}}
|
||||||
return obj;
|
{{#allowableValues}}{{#enumVars}}{{#-first}}{{^isString}}return QJsonValue(static_cast<int>(m_value));{{/isString}}{{#isString}}return QJsonValue(asJson());{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{{dataType}}}
|
{{{dataType}}}
|
||||||
{{classname}}::{{getter}}() const {
|
{{classname}}::{{getter}}() const {
|
||||||
return {{name}};
|
return {{name}};
|
||||||
@ -105,20 +125,30 @@ void
|
|||||||
this->m_{{name}}_isSet = true;
|
this->m_{{name}}_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||||
|
{{classname}}::e{{classname}} {{classname}}::getValue() const {
|
||||||
|
return m_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void {{classname}}::setValue(const {{classname}}::e{{classname}}& value){
|
||||||
|
m_value = value;
|
||||||
|
m_value_isSet = true;
|
||||||
|
}
|
||||||
|
{{/isEnum}}
|
||||||
bool
|
bool
|
||||||
{{classname}}::isSet() const {
|
{{classname}}::isSet() const {
|
||||||
bool isObjectUpdated = false;
|
{{^isEnum}}bool isObjectUpdated = false;
|
||||||
do{ {{#vars}}
|
do{ {{#vars}}
|
||||||
{{#isContainer}}if({{name}}.size() > 0){{/isContainer}}{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{{/isContainer}}{ isObjectUpdated = true; break;}
|
{{#isContainer}}if({{name}}.size() > 0){{/isContainer}}{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{{/isContainer}}{ isObjectUpdated = true; break;}
|
||||||
{{/vars}}}while(false);
|
{{/vars}}}while(false);
|
||||||
return isObjectUpdated;
|
return isObjectUpdated;{{/isEnum}}{{#isEnum}}
|
||||||
|
return m_value_isSet;{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
{{classname}}::isValid() const {
|
{{classname}}::isValid() const {
|
||||||
// only required properties are required for the object to be considered valid
|
// only required properties are required for the object to be considered valid
|
||||||
return {{#vars}}{{#required}}m_{{name}}_isValid && {{/required}}{{/vars}}true;
|
return {{^isEnum}}{{#vars}}{{#required}}m_{{name}}_isValid && {{/required}}{{/vars}}true{{/isEnum}}{{#isEnum}}m_value_isValid{{/isEnum}};
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
#include "{{prefix}}Object.h"
|
#include "{{prefix}}Object.h"
|
||||||
|
#include "{{prefix}}Enum.h"
|
||||||
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
@ -22,32 +23,51 @@
|
|||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
class {{classname}}: public {{prefix}}Object {
|
class {{classname}}: public {{prefix}}{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Enum{{/isEnum}} {
|
||||||
public:
|
public:
|
||||||
{{classname}}();
|
{{classname}}();
|
||||||
{{classname}}(QString json);
|
{{classname}}(QString json);
|
||||||
~{{classname}}() override;
|
~{{classname}}() override;
|
||||||
|
|
||||||
QString asJson () const override;
|
QString asJson () const override;
|
||||||
QJsonObject asJsonObject() const override;
|
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const override;
|
||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{{dataType}}} {{getter}}() const;
|
{{{dataType}}} {{getter}}() const;
|
||||||
void {{setter}}(const {{{dataType}}} &{{name}});
|
void {{setter}}(const {{{dataType}}} &{{name}});
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}{{#allowableValues}}
|
||||||
|
enum class e{{classname}} {{#enumVars}}{{#-first}}{{^isString}}: int {{/isString}}{{/-first}}{{/enumVars}}{
|
||||||
|
INVALID_VALUE_OPENAPI_GENERATED = 0,
|
||||||
|
{{#enumVars}}
|
||||||
|
{{#enumDescription}}
|
||||||
|
/**
|
||||||
|
* {{enumDescription}}
|
||||||
|
*/
|
||||||
|
{{/enumDescription}}
|
||||||
|
{{{name}}}{{^-last}}, {{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
};{{/allowableValues}}
|
||||||
|
|
||||||
|
{{classname}}::e{{classname}} getValue() const;
|
||||||
|
void setValue(const {{classname}}::e{{classname}}& value);{{/isEnum}}
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{{dataType}}} {{name}};
|
{{{dataType}}} {{name}};
|
||||||
bool m_{{name}}_isSet;
|
bool m_{{name}}_isSet;
|
||||||
bool m_{{name}}_isValid;
|
bool m_{{name}}_isValid;
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}
|
||||||
|
{{#isEnum}}e{{classname}} m_value;
|
||||||
|
bool m_value_isSet;
|
||||||
|
bool m_value_isValid;
|
||||||
|
{{/isEnum}}
|
||||||
};
|
};
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -116,9 +116,10 @@ void {{classname}}Request::{{nickname}}Request({{#hasPathParams}}{{#pathParams}}
|
|||||||
{{#operations}}{{#operation}}void {{classname}}Request::{{nickname}}Response({{#returnType}}const {{{returnType}}}& res{{/returnType}}){
|
{{#operations}}{{#operation}}void {{classname}}Request::{{nickname}}Response({{#returnType}}const {{{returnType}}}& res{{/returnType}}){
|
||||||
writeResponseHeaders();{{#returnType}}{{#isMapContainer}}
|
writeResponseHeaders();{{#returnType}}{{#isMapContainer}}
|
||||||
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).toObject());
|
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).toObject());
|
||||||
socket->writeJson(resDoc);{{/isMapContainer}}{{^isMapContainer}}{{^returnTypeIsPrimitive}}
|
socket->writeJson(resDoc);{{/isMapContainer}}{{^isMapContainer}}{{^returnTypeIsPrimitive}}{{^vendorExtensions.returnsEnum}}
|
||||||
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).to{{^isListContainer}}Object{{/isListContainer}}{{#isListContainer}}Array{{/isListContainer}}());
|
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).to{{^isListContainer}}Object{{/isListContainer}}{{#isListContainer}}Array{{/isListContainer}}());
|
||||||
socket->writeJson(resDoc);{{/returnTypeIsPrimitive}}{{#returnTypeIsPrimitive}}
|
socket->writeJson(resDoc);{{/vendorExtensions.returnsEnum}}{{#vendorExtensions.returnsEnum}}
|
||||||
|
socket->write(::{{cppNamespace}}::toStringValue(res).toUtf8());{{/vendorExtensions.returnsEnum}}{{/returnTypeIsPrimitive}}{{#returnTypeIsPrimitive}}
|
||||||
socket->write({{#isListContainer}}QString("["+{{/isListContainer}}::{{cppNamespace}}::toStringValue(res){{#isListContainer}}+"]"){{/isListContainer}}.toUtf8());{{/returnTypeIsPrimitive}}{{/isMapContainer}}{{/returnType}}{{^returnType}}
|
socket->write({{#isListContainer}}QString("["+{{/isListContainer}}::{{cppNamespace}}::toStringValue(res){{#isListContainer}}+"]"){{/isListContainer}}.toUtf8());{{/returnTypeIsPrimitive}}{{/isMapContainer}}{{/returnType}}{{^returnType}}
|
||||||
socket->setStatusCode(QHttpEngine::Socket::OK);{{/returnType}}
|
socket->setStatusCode(QHttpEngine::Socket::OK);{{/returnType}}
|
||||||
if(socket->isOpen()){
|
if(socket->isOpen()){
|
||||||
@ -132,9 +133,10 @@ void {{classname}}Request::{{nickname}}Request({{#hasPathParams}}{{#pathParams}}
|
|||||||
writeResponseHeaders();{{#returnType}}
|
writeResponseHeaders();{{#returnType}}
|
||||||
Q_UNUSED(error_str); // response will be used instead of error string{{#isMapContainer}}
|
Q_UNUSED(error_str); // response will be used instead of error string{{#isMapContainer}}
|
||||||
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).toObject());
|
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).toObject());
|
||||||
socket->writeJson(resDoc);{{/isMapContainer}}{{^isMapContainer}}{{^returnTypeIsPrimitive}}
|
socket->writeJson(resDoc);{{/isMapContainer}}{{^isMapContainer}}{{^returnTypeIsPrimitive}}{{^vendorExtensions.returnsEnum}}
|
||||||
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).to{{^isListContainer}}Object{{/isListContainer}}{{#isListContainer}}Array{{/isListContainer}}());
|
QJsonDocument resDoc(::{{cppNamespace}}::toJsonValue(res).to{{^isListContainer}}Object{{/isListContainer}}{{#isListContainer}}Array{{/isListContainer}}());
|
||||||
socket->writeJson(resDoc);{{/returnTypeIsPrimitive}}{{#returnTypeIsPrimitive}}
|
socket->writeJson(resDoc);{{/vendorExtensions.returnsEnum}}{{#vendorExtensions.returnsEnum}}
|
||||||
|
socket->write(::{{cppNamespace}}::toStringValue(res).toUtf8());{{/vendorExtensions.returnsEnum}}{{/returnTypeIsPrimitive}}{{#returnTypeIsPrimitive}}
|
||||||
socket->write({{#isListContainer}}QString("["+{{/isListContainer}}::{{cppNamespace}}::toStringValue(res){{#isListContainer}}+"]"){{/isListContainer}}.toUtf8());{{/returnTypeIsPrimitive}}{{/isMapContainer}}{{/returnType}}{{^returnType}}
|
socket->write({{#isListContainer}}QString("["+{{/isListContainer}}::{{cppNamespace}}::toStringValue(res){{#isListContainer}}+"]"){{/isListContainer}}.toUtf8());{{/returnTypeIsPrimitive}}{{/isMapContainer}}{{/returnType}}{{^returnType}}
|
||||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||||
socket->write(error_str.toUtf8());{{/returnType}}
|
socket->write(error_str.toUtf8());{{/returnType}}
|
||||||
|
57
modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/enum.mustache
vendored
Normal file
57
modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/enum.mustache
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{{>licenseInfo}}
|
||||||
|
#ifndef {{prefix}}_ENUM_H
|
||||||
|
#define {{prefix}}_ENUM_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
{{#cppNamespaceDeclarations}}
|
||||||
|
namespace {{this}} {
|
||||||
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
|
class {{prefix}}Enum {
|
||||||
|
public:
|
||||||
|
{{prefix}}Enum() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{{prefix}}Enum(QString jsonString) {
|
||||||
|
fromJson(jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~{{prefix}}Enum(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QJsonValue asJsonValue() const {
|
||||||
|
return QJsonValue(jstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString asJson() const {
|
||||||
|
return jstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void fromJson(QString jsonString) {
|
||||||
|
jstr = jsonString;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void fromJsonValue(QJsonValue jval) {
|
||||||
|
jstr = jval.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isSet() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isValid() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private :
|
||||||
|
QString jstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
{{#cppNamespaceDeclarations}}
|
||||||
|
}
|
||||||
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
|
#endif // {{prefix}}_ENUM_H
|
@ -1,7 +1,7 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "{{prefix}}Helpers.h"
|
#include "{{prefix}}Helpers.h"
|
||||||
#include "{{prefix}}Object.h"
|
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
@ -55,6 +55,11 @@ toStringValue(const double &value){
|
|||||||
return QString::number(value);
|
return QString::number(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
toStringValue(const {{prefix}}Enum &value){
|
||||||
|
return value.asJson();
|
||||||
|
}
|
||||||
|
|
||||||
QJsonValue
|
QJsonValue
|
||||||
toJsonValue(const QString &value){
|
toJsonValue(const QString &value){
|
||||||
return QJsonValue(value);
|
return QJsonValue(value);
|
||||||
@ -105,6 +110,11 @@ toJsonValue(const {{prefix}}Object &value){
|
|||||||
return value.asJsonObject();
|
return value.asJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonValue
|
||||||
|
toJsonValue(const {{prefix}}Enum &value){
|
||||||
|
return value.asJsonValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fromStringValue(const QString &inStr, QString &value){
|
fromStringValue(const QString &inStr, QString &value){
|
||||||
value.clear();
|
value.clear();
|
||||||
@ -193,6 +203,12 @@ fromStringValue(const QString &inStr, double &value){
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fromStringValue(const QString &inStr, {{prefix}}Enum &value){
|
||||||
|
value.fromJson(inStr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fromJsonValue(QString &value, const QJsonValue &jval){
|
fromJsonValue(QString &value, const QJsonValue &jval){
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
@ -315,6 +331,12 @@ fromJsonValue({{prefix}}Object &value, const QJsonValue &jval){
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval){
|
||||||
|
value.fromJsonValue(jval);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
}
|
}
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "{{prefix}}Object.h"
|
#include "{{prefix}}Object.h"
|
||||||
|
#include "{{prefix}}Enum.h"
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
@ -26,6 +27,7 @@ namespace {{this}} {
|
|||||||
QString toStringValue(const bool &value);
|
QString toStringValue(const bool &value);
|
||||||
QString toStringValue(const float &value);
|
QString toStringValue(const float &value);
|
||||||
QString toStringValue(const double &value);
|
QString toStringValue(const double &value);
|
||||||
|
QString toStringValue(const {{prefix}}Enum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QString toStringValue(const QList<T> &val) {
|
QString toStringValue(const QList<T> &val) {
|
||||||
@ -49,6 +51,7 @@ namespace {{this}} {
|
|||||||
QJsonValue toJsonValue(const float &value);
|
QJsonValue toJsonValue(const float &value);
|
||||||
QJsonValue toJsonValue(const double &value);
|
QJsonValue toJsonValue(const double &value);
|
||||||
QJsonValue toJsonValue(const {{prefix}}Object &value);
|
QJsonValue toJsonValue(const {{prefix}}Object &value);
|
||||||
|
QJsonValue toJsonValue(const {{prefix}}Enum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QJsonValue toJsonValue(const QList<T> &val) {
|
QJsonValue toJsonValue(const QList<T> &val) {
|
||||||
@ -77,6 +80,7 @@ namespace {{this}} {
|
|||||||
bool fromStringValue(const QString &inStr, bool &value);
|
bool fromStringValue(const QString &inStr, bool &value);
|
||||||
bool fromStringValue(const QString &inStr, float &value);
|
bool fromStringValue(const QString &inStr, float &value);
|
||||||
bool fromStringValue(const QString &inStr, double &value);
|
bool fromStringValue(const QString &inStr, double &value);
|
||||||
|
bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||||
@ -110,6 +114,7 @@ namespace {{this}} {
|
|||||||
bool fromJsonValue(float &value, const QJsonValue &jval);
|
bool fromJsonValue(float &value, const QJsonValue &jval);
|
||||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||||
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
|
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
|
||||||
|
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||||
|
@ -28,23 +28,31 @@ namespace {{this}} {
|
|||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::init() {
|
{{classname}}::init() {
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
m_{{name}}_isSet = false;
|
m_{{name}}_isSet = false;
|
||||||
m_{{name}}_isValid = false;
|
m_{{name}}_isValid = false;
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||||
|
m_value_isSet = false;
|
||||||
|
m_value_isValid = false;
|
||||||
|
m_value = e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED;
|
||||||
|
{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::fromJson(QString jsonString) {
|
{{classname}}::fromJson(QString jsonString) {
|
||||||
QByteArray array (jsonString.toStdString().c_str());
|
{{^isEnum}}QByteArray array (jsonString.toStdString().c_str());
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||||
QJsonObject jsonObject = doc.object();
|
QJsonObject jsonObject = doc.object();
|
||||||
this->fromJsonObject(jsonObject);
|
this->fromJsonObject(jsonObject);{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}
|
||||||
|
{{#-first}}if{{/-first}}{{^-first}}else if{{/-first}} ( jsonString.compare({{#isString}}"{{value}}"{{/isString}}{{^isString}}QString::number({{value}}){{/isString}}, Qt::CaseInsensitive) == 0) {
|
||||||
|
m_value = e{{classname}}::{{name}};
|
||||||
|
m_value_isValid = true;
|
||||||
|
}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::fromJsonObject(QJsonObject json) {
|
{{classname}}::fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) {
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{^isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/isContainer}}
|
{{^isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/isContainer}}
|
||||||
{{#isContainer}}{{^items.isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}}
|
{{#isContainer}}{{^items.isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}}
|
||||||
if(json["{{baseName}}"].isArray()){
|
if(json["{{baseName}}"].isArray()){
|
||||||
@ -68,33 +76,45 @@ void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}{{/isMapContainer}}{{/items.isContainer}}{{/isContainer}}
|
}{{/isMapContainer}}{{/items.isContainer}}{{/isContainer}}
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||||
|
{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}fromJson(json.toString());{{/isString}}{{^isString}}m_value = static_cast<e{{classname}}>(json.toInt());{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
{{classname}}::asJson () const {
|
{{classname}}::asJson () const {
|
||||||
QJsonObject obj = this->asJsonObject();
|
{{^isEnum}}QJsonObject obj = this->asJsonObject();
|
||||||
QJsonDocument doc(obj);
|
QJsonDocument doc(obj);
|
||||||
QByteArray bytes = doc.toJson();
|
QByteArray bytes = doc.toJson();
|
||||||
return QString(bytes);
|
return QString(bytes);{{/isEnum}}{{#isEnum}}
|
||||||
|
QString val;
|
||||||
|
{{#allowableValues}}
|
||||||
|
switch (m_value){
|
||||||
|
{{#enumVars}}
|
||||||
|
case e{{classname}}::{{name}}:
|
||||||
|
val = {{#isString}}"{{value}}"{{/isString}}{{^isString}}QString::number({{value}}){{/isString}};
|
||||||
|
break;{{#-last}}
|
||||||
|
default:
|
||||||
|
break;{{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
}{{/allowableValues}}
|
||||||
|
return val;{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject
|
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}
|
||||||
{{classname}}::asJsonObject() const {
|
{{classname}}::asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const {
|
||||||
QJsonObject obj;
|
{{^isEnum}}QJsonObject obj;{{#vars}}
|
||||||
{{#vars}}
|
|
||||||
{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
|
{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
|
||||||
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
|
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
|
||||||
}{{/isContainer}}{{#isContainer}}
|
}{{/isContainer}}{{#isContainer}}
|
||||||
if({{name}}.size() > 0){
|
if({{name}}.size() > 0){
|
||||||
{{^items.isContainer}}obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));{{/items.isContainer}}{{#items.isContainer}}
|
{{^items.isContainer}}obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));{{/items.isContainer}}{{#items.isContainer}}
|
||||||
obj.insert(QString("{{baseName}}"), toJsonValue({{name}}));{{/items.isContainer}}
|
obj.insert(QString("{{baseName}}"), toJsonValue({{name}}));{{/items.isContainer}}
|
||||||
} {{/isContainer}}
|
} {{/isContainer}}{{/vars}}
|
||||||
{{/vars}}
|
return obj;{{/isEnum}}{{#isEnum}}
|
||||||
return obj;
|
{{#allowableValues}}{{#enumVars}}{{#-first}}{{^isString}}return QJsonValue(static_cast<int>(m_value));{{/isString}}{{#isString}}return QJsonValue(asJson());{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{{dataType}}}
|
{{{dataType}}}
|
||||||
{{classname}}::{{getter}}() const {
|
{{classname}}::{{getter}}() const {
|
||||||
return {{name}};
|
return {{name}};
|
||||||
@ -105,20 +125,30 @@ void
|
|||||||
this->m_{{name}}_isSet = true;
|
this->m_{{name}}_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||||
|
{{classname}}::e{{classname}} {{classname}}::getValue() const {
|
||||||
|
return m_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void {{classname}}::setValue(const {{classname}}::e{{classname}}& value){
|
||||||
|
m_value = value;
|
||||||
|
m_value_isSet = true;
|
||||||
|
}
|
||||||
|
{{/isEnum}}
|
||||||
bool
|
bool
|
||||||
{{classname}}::isSet() const {
|
{{classname}}::isSet() const {
|
||||||
bool isObjectUpdated = false;
|
{{^isEnum}}bool isObjectUpdated = false;
|
||||||
do{ {{#vars}}
|
do{ {{#vars}}
|
||||||
{{#isContainer}}if({{name}}.size() > 0){{/isContainer}}{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{{/isContainer}}{ isObjectUpdated = true; break;}
|
{{#isContainer}}if({{name}}.size() > 0){{/isContainer}}{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{{/isContainer}}{ isObjectUpdated = true; break;}
|
||||||
{{/vars}}}while(false);
|
{{/vars}}}while(false);
|
||||||
return isObjectUpdated;
|
return isObjectUpdated;{{/isEnum}}{{#isEnum}}
|
||||||
|
return m_value_isSet;{{/isEnum}}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
{{classname}}::isValid() const {
|
{{classname}}::isValid() const {
|
||||||
// only required properties are required for the object to be considered valid
|
// only required properties are required for the object to be considered valid
|
||||||
return {{#vars}}{{#required}}m_{{name}}_isValid && {{/required}}{{/vars}}true;
|
return {{^isEnum}}{{#vars}}{{#required}}m_{{name}}_isValid && {{/required}}{{/vars}}true{{/isEnum}}{{#isEnum}}m_value_isValid{{/isEnum}};
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
#include "{{prefix}}Object.h"
|
#include "{{prefix}}Object.h"
|
||||||
|
#include "{{prefix}}Enum.h"
|
||||||
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
@ -22,32 +23,51 @@
|
|||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
class {{classname}}: public {{prefix}}Object {
|
class {{classname}}: public {{prefix}}{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Enum{{/isEnum}} {
|
||||||
public:
|
public:
|
||||||
{{classname}}();
|
{{classname}}();
|
||||||
{{classname}}(QString json);
|
{{classname}}(QString json);
|
||||||
~{{classname}}() override;
|
~{{classname}}() override;
|
||||||
|
|
||||||
QString asJson () const override;
|
QString asJson () const override;
|
||||||
QJsonObject asJsonObject() const override;
|
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const override;
|
||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{{dataType}}} {{getter}}() const;
|
{{{dataType}}} {{getter}}() const;
|
||||||
void {{setter}}(const {{{dataType}}} &{{name}});
|
void {{setter}}(const {{{dataType}}} &{{name}});
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}{{#isEnum}}{{#allowableValues}}
|
||||||
|
enum class e{{classname}} {{#enumVars}}{{#-first}}{{^isString}}: int {{/isString}}{{/-first}}{{/enumVars}}{
|
||||||
|
INVALID_VALUE_OPENAPI_GENERATED = 0,
|
||||||
|
{{#enumVars}}
|
||||||
|
{{#enumDescription}}
|
||||||
|
/**
|
||||||
|
* {{enumDescription}}
|
||||||
|
*/
|
||||||
|
{{/enumDescription}}
|
||||||
|
{{{name}}}{{^-last}}, {{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
};{{/allowableValues}}
|
||||||
|
|
||||||
|
{{classname}}::e{{classname}} getValue() const;
|
||||||
|
void setValue(const {{classname}}::e{{classname}}& value);{{/isEnum}}
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
{{#vars}}
|
{{^isEnum}}{{#vars}}
|
||||||
{{{dataType}}} {{name}};
|
{{{dataType}}} {{name}};
|
||||||
bool m_{{name}}_isSet;
|
bool m_{{name}}_isSet;
|
||||||
bool m_{{name}}_isValid;
|
bool m_{{name}}_isValid;
|
||||||
{{/vars}}
|
{{/vars}}{{/isEnum}}
|
||||||
|
{{#isEnum}}e{{classname}} m_value;
|
||||||
|
bool m_value_isSet;
|
||||||
|
bool m_value_isValid;
|
||||||
|
{{/isEnum}}
|
||||||
};
|
};
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -20,7 +20,9 @@ include(../client/client.pri)
|
|||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
PetApiTests.cpp \
|
PetApiTests.cpp \
|
||||||
StoreApiTests.cpp
|
StoreApiTests.cpp \
|
||||||
|
UserApiTests.cpp
|
||||||
|
|
||||||
HEADERS += PetApiTests.h \
|
HEADERS += PetApiTests.h \
|
||||||
StoreApiTests.h
|
StoreApiTests.h \
|
||||||
|
UserApiTests.h
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
StoreApiTests::StoreApiTests () {}
|
StoreApiTests::StoreApiTests () {}
|
||||||
|
|
||||||
StoreApiTests::~StoreApiTests () {
|
StoreApiTests::~StoreApiTests () {
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OAIStoreApi* StoreApiTests::getApi() {
|
OAIStoreApi* StoreApiTests::getApi() {
|
||||||
|
@ -17,8 +17,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
OAIStoreApi* getApi();
|
OAIStoreApi* getApi();
|
||||||
OAIOrder createRandomOrder();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void quit();
|
void quit();
|
||||||
bool success();
|
bool success();
|
||||||
|
252
samples/client/petstore/cpp-qt5/PetStore/UserApiTests.cpp
Normal file
252
samples/client/petstore/cpp-qt5/PetStore/UserApiTests.cpp
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
#include "UserApiTests.h"
|
||||||
|
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
UserApiTests::UserApiTests () {}
|
||||||
|
|
||||||
|
UserApiTests::~UserApiTests () {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
OAIUserApi* UserApiTests::getApi() {
|
||||||
|
auto api = new OAIUserApi();
|
||||||
|
api->host = "http://petstore.swagger.io";
|
||||||
|
api->basePath = "/v2";
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::runTests() {
|
||||||
|
UserApiTests* tests = new UserApiTests();
|
||||||
|
QTest::qExec(tests);
|
||||||
|
delete tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
OAIUser UserApiTests::createRandomUser() {
|
||||||
|
OAIUser user;
|
||||||
|
user.setId(QDateTime::currentMSecsSinceEpoch());
|
||||||
|
user.setEmail(QString("Jane.Doe@openapitools.io"));
|
||||||
|
user.setFirstName(QString("Jane"));
|
||||||
|
user.setLastName(QString("Doe"));
|
||||||
|
user.setPhone(QString("123456789"));
|
||||||
|
user.setUsername(QString("janedoe"));
|
||||||
|
user.setPassword(QString("secretPassword"));
|
||||||
|
user.setUserStatus(static_cast<int>(QRandomGenerator::system()->generate()));
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::createUserTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(14000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this]() {
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::createUserSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
|
||||||
|
api->createUser(createRandomUser());
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::createUsersWithArrayInputTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(14000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this]() {
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::createUsersWithArrayInputSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
QList<OAIUser> users;
|
||||||
|
users.append(createRandomUser());
|
||||||
|
users.append(createRandomUser());
|
||||||
|
users.append(createRandomUser());
|
||||||
|
api->createUsersWithArrayInput(users);
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::createUsersWithListInputTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(14000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this]() {
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::createUsersWithListInputSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
QList<OAIUser> users;
|
||||||
|
auto johndoe = createRandomUser();
|
||||||
|
johndoe.setUsername(QString("johndoe"));
|
||||||
|
auto rambo = createRandomUser();
|
||||||
|
rambo.setUsername(QString("rambo"));
|
||||||
|
users.append(johndoe);
|
||||||
|
users.append(rambo);
|
||||||
|
users.append(createRandomUser());
|
||||||
|
api->createUsersWithListInput(users);
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::deleteUserTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(14000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this]() {
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::deleteUserSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
|
||||||
|
api->deleteUser(QString("rambo"));
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::getUserByNameTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(30000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this](OAIUser summary) {
|
||||||
|
qDebug() << summary.getUsername();
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::getUserByNameSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
|
||||||
|
api->getUserByName(QString("johndoe"));
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::loginUserTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(30000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this](QString summary) {
|
||||||
|
qDebug() << summary;
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::loginUserSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
|
||||||
|
api->loginUser(QString("johndoe"), QString("123456789"));
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::logoutUserTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(30000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this]() {
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::logoutUserSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
|
||||||
|
api->logoutUser();
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserApiTests::updateUserTest(){
|
||||||
|
auto api = getApi();
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(30000);
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
auto validator = [this]() {
|
||||||
|
emit quit();
|
||||||
|
};
|
||||||
|
auto finalizer = [&]() {
|
||||||
|
loop.quit();
|
||||||
|
};
|
||||||
|
connect(this, &UserApiTests::quit, finalizer);
|
||||||
|
connect(api, &OAIUserApi::updateUserSignal, this, validator);
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, finalizer);
|
||||||
|
|
||||||
|
auto johndoe = createRandomUser();
|
||||||
|
johndoe.setUsername(QString("johndoe"));
|
||||||
|
api->updateUser(QString("johndoe"), johndoe);
|
||||||
|
timer.start();
|
||||||
|
loop.exec();
|
||||||
|
QVERIFY2(timer.isActive(), "didn't finish within timeout");
|
||||||
|
disconnect(this, nullptr, nullptr, nullptr);
|
||||||
|
delete api;
|
||||||
|
}
|
37
samples/client/petstore/cpp-qt5/PetStore/UserApiTests.h
Normal file
37
samples/client/petstore/cpp-qt5/PetStore/UserApiTests.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef USERAPITESTS_H
|
||||||
|
#define USERAPITESTS_H
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "../client/OAIUserApi.h"
|
||||||
|
|
||||||
|
using namespace OpenAPI;
|
||||||
|
|
||||||
|
class UserApiTests: public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
UserApiTests();
|
||||||
|
virtual ~UserApiTests();
|
||||||
|
|
||||||
|
static void runTests();
|
||||||
|
|
||||||
|
private:
|
||||||
|
OAIUserApi* getApi();
|
||||||
|
OAIUser createRandomUser();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void quit();
|
||||||
|
bool success();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void createUserTest();
|
||||||
|
void createUsersWithArrayInputTest();
|
||||||
|
void createUsersWithListInputTest();
|
||||||
|
void deleteUserTest();
|
||||||
|
void getUserByNameTest();
|
||||||
|
void loginUserTest();
|
||||||
|
void logoutUserTest();
|
||||||
|
void updateUserTest();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USERAPITESTS_H
|
@ -1,10 +1,12 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include "PetApiTests.h"
|
#include "PetApiTests.h"
|
||||||
#include "StoreApiTests.h"
|
#include "StoreApiTests.h"
|
||||||
|
#include "UserApiTests.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
PetApiTests::runTests();
|
PetApiTests::runTests();
|
||||||
StoreApiTests::runTests();
|
StoreApiTests::runTests();
|
||||||
|
UserApiTests::runTests();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,16 @@ OAIApiResponse::~OAIApiResponse() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIApiResponse::init() {
|
OAIApiResponse::init() {
|
||||||
|
|
||||||
m_code_isSet = false;
|
m_code_isSet = false;
|
||||||
m_code_isValid = false;
|
m_code_isValid = false;
|
||||||
|
|
||||||
m_type_isSet = false;
|
m_type_isSet = false;
|
||||||
m_type_isValid = false;
|
m_type_isValid = false;
|
||||||
|
|
||||||
m_message_isSet = false;
|
m_message_isSet = false;
|
||||||
m_message_isValid = false;
|
m_message_isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OAIApiResponse::fromJson(QString jsonString) {
|
OAIApiResponse::fromJson(QString jsonString) {
|
||||||
@ -55,12 +58,16 @@ OAIApiResponse::fromJson(QString jsonString) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIApiResponse::fromJsonObject(QJsonObject json) {
|
OAIApiResponse::fromJsonObject(QJsonObject json) {
|
||||||
|
|
||||||
m_code_isValid = ::OpenAPI::fromJsonValue(code, json[QString("code")]);
|
m_code_isValid = ::OpenAPI::fromJsonValue(code, json[QString("code")]);
|
||||||
|
|
||||||
|
|
||||||
m_type_isValid = ::OpenAPI::fromJsonValue(type, json[QString("type")]);
|
m_type_isValid = ::OpenAPI::fromJsonValue(type, json[QString("type")]);
|
||||||
|
|
||||||
|
|
||||||
m_message_isValid = ::OpenAPI::fromJsonValue(message, json[QString("message")]);
|
m_message_isValid = ::OpenAPI::fromJsonValue(message, json[QString("message")]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -86,6 +93,7 @@ OAIApiResponse::asJsonObject() const {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
OAIApiResponse::getCode() const {
|
OAIApiResponse::getCode() const {
|
||||||
return code;
|
return code;
|
||||||
@ -96,6 +104,7 @@ OAIApiResponse::setCode(const qint32 &code) {
|
|||||||
this->m_code_isSet = true;
|
this->m_code_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIApiResponse::getType() const {
|
OAIApiResponse::getType() const {
|
||||||
return type;
|
return type;
|
||||||
@ -106,6 +115,7 @@ OAIApiResponse::setType(const QString &type) {
|
|||||||
this->m_type_isSet = true;
|
this->m_type_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIApiResponse::getMessage() const {
|
OAIApiResponse::getMessage() const {
|
||||||
return message;
|
return message;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "OAIObject.h"
|
#include "OAIObject.h"
|
||||||
|
#include "OAIEnum.h"
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -39,30 +40,39 @@ public:
|
|||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJsonObject(QJsonObject json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
|
|
||||||
qint32 getCode() const;
|
qint32 getCode() const;
|
||||||
void setCode(const qint32 &code);
|
void setCode(const qint32 &code);
|
||||||
|
|
||||||
|
|
||||||
QString getType() const;
|
QString getType() const;
|
||||||
void setType(const QString &type);
|
void setType(const QString &type);
|
||||||
|
|
||||||
|
|
||||||
QString getMessage() const;
|
QString getMessage() const;
|
||||||
void setMessage(const QString &message);
|
void setMessage(const QString &message);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
qint32 code;
|
qint32 code;
|
||||||
bool m_code_isSet;
|
bool m_code_isSet;
|
||||||
bool m_code_isValid;
|
bool m_code_isValid;
|
||||||
|
|
||||||
QString type;
|
QString type;
|
||||||
bool m_type_isSet;
|
bool m_type_isSet;
|
||||||
bool m_type_isValid;
|
bool m_type_isValid;
|
||||||
|
|
||||||
QString message;
|
QString message;
|
||||||
bool m_message_isSet;
|
bool m_message_isSet;
|
||||||
bool m_message_isValid;
|
bool m_message_isValid;
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,11 +37,13 @@ OAICategory::~OAICategory() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAICategory::init() {
|
OAICategory::init() {
|
||||||
|
|
||||||
m_id_isSet = false;
|
m_id_isSet = false;
|
||||||
m_id_isValid = false;
|
m_id_isValid = false;
|
||||||
|
|
||||||
m_name_isSet = false;
|
m_name_isSet = false;
|
||||||
m_name_isValid = false;
|
m_name_isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OAICategory::fromJson(QString jsonString) {
|
OAICategory::fromJson(QString jsonString) {
|
||||||
@ -53,10 +55,13 @@ OAICategory::fromJson(QString jsonString) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAICategory::fromJsonObject(QJsonObject json) {
|
OAICategory::fromJsonObject(QJsonObject json) {
|
||||||
|
|
||||||
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||||
|
|
||||||
|
|
||||||
m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -79,6 +84,7 @@ OAICategory::asJsonObject() const {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint64
|
qint64
|
||||||
OAICategory::getId() const {
|
OAICategory::getId() const {
|
||||||
return id;
|
return id;
|
||||||
@ -89,6 +95,7 @@ OAICategory::setId(const qint64 &id) {
|
|||||||
this->m_id_isSet = true;
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAICategory::getName() const {
|
OAICategory::getName() const {
|
||||||
return name;
|
return name;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "OAIObject.h"
|
#include "OAIObject.h"
|
||||||
|
#include "OAIEnum.h"
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -39,24 +40,31 @@ public:
|
|||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJsonObject(QJsonObject json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
|
|
||||||
qint64 getId() const;
|
qint64 getId() const;
|
||||||
void setId(const qint64 &id);
|
void setId(const qint64 &id);
|
||||||
|
|
||||||
|
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
qint64 id;
|
qint64 id;
|
||||||
bool m_id_isSet;
|
bool m_id_isSet;
|
||||||
bool m_id_isValid;
|
bool m_id_isValid;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
bool m_name_isSet;
|
bool m_name_isSet;
|
||||||
bool m_name_isValid;
|
bool m_name_isValid;
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
64
samples/client/petstore/cpp-qt5/client/OAIEnum.h
Normal file
64
samples/client/petstore/cpp-qt5/client/OAIEnum.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 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 OAI_ENUM_H
|
||||||
|
#define OAI_ENUM_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
namespace OpenAPI {
|
||||||
|
|
||||||
|
class OAIEnum {
|
||||||
|
public:
|
||||||
|
OAIEnum() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OAIEnum(QString jsonString) {
|
||||||
|
fromJson(jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~OAIEnum(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QJsonValue asJsonValue() const {
|
||||||
|
return QJsonValue(jstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString asJson() const {
|
||||||
|
return jstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void fromJson(QString jsonString) {
|
||||||
|
jstr = jsonString;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void fromJsonValue(QJsonValue jval) {
|
||||||
|
jstr = jval.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isSet() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isValid() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private :
|
||||||
|
QString jstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // OAI_ENUM_H
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "OAIHelpers.h"
|
#include "OAIHelpers.h"
|
||||||
#include "OAIObject.h"
|
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -64,6 +64,11 @@ toStringValue(const double &value){
|
|||||||
return QString::number(value);
|
return QString::number(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
toStringValue(const OAIEnum &value){
|
||||||
|
return value.asJson();
|
||||||
|
}
|
||||||
|
|
||||||
QJsonValue
|
QJsonValue
|
||||||
toJsonValue(const QString &value){
|
toJsonValue(const QString &value){
|
||||||
return QJsonValue(value);
|
return QJsonValue(value);
|
||||||
@ -114,6 +119,11 @@ toJsonValue(const OAIObject &value){
|
|||||||
return value.asJsonObject();
|
return value.asJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonValue
|
||||||
|
toJsonValue(const OAIEnum &value){
|
||||||
|
return value.asJsonValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fromStringValue(const QString &inStr, QString &value){
|
fromStringValue(const QString &inStr, QString &value){
|
||||||
value.clear();
|
value.clear();
|
||||||
@ -202,6 +212,12 @@ fromStringValue(const QString &inStr, double &value){
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fromStringValue(const QString &inStr, OAIEnum &value){
|
||||||
|
value.fromJson(inStr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fromJsonValue(QString &value, const QJsonValue &jval){
|
fromJsonValue(QString &value, const QJsonValue &jval){
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
@ -324,4 +340,10 @@ fromJsonValue(OAIObject &value, const QJsonValue &jval){
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fromJsonValue(OAIEnum &value, const QJsonValue &jval){
|
||||||
|
value.fromJsonValue(jval);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "OAIObject.h"
|
#include "OAIObject.h"
|
||||||
|
#include "OAIEnum.h"
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ namespace OpenAPI {
|
|||||||
QString toStringValue(const bool &value);
|
QString toStringValue(const bool &value);
|
||||||
QString toStringValue(const float &value);
|
QString toStringValue(const float &value);
|
||||||
QString toStringValue(const double &value);
|
QString toStringValue(const double &value);
|
||||||
|
QString toStringValue(const OAIEnum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QString toStringValue(const QList<T> &val) {
|
QString toStringValue(const QList<T> &val) {
|
||||||
@ -58,6 +60,7 @@ namespace OpenAPI {
|
|||||||
QJsonValue toJsonValue(const float &value);
|
QJsonValue toJsonValue(const float &value);
|
||||||
QJsonValue toJsonValue(const double &value);
|
QJsonValue toJsonValue(const double &value);
|
||||||
QJsonValue toJsonValue(const OAIObject &value);
|
QJsonValue toJsonValue(const OAIObject &value);
|
||||||
|
QJsonValue toJsonValue(const OAIEnum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QJsonValue toJsonValue(const QList<T> &val) {
|
QJsonValue toJsonValue(const QList<T> &val) {
|
||||||
@ -86,6 +89,7 @@ namespace OpenAPI {
|
|||||||
bool fromStringValue(const QString &inStr, bool &value);
|
bool fromStringValue(const QString &inStr, bool &value);
|
||||||
bool fromStringValue(const QString &inStr, float &value);
|
bool fromStringValue(const QString &inStr, float &value);
|
||||||
bool fromStringValue(const QString &inStr, double &value);
|
bool fromStringValue(const QString &inStr, double &value);
|
||||||
|
bool fromStringValue(const QString &inStr, OAIEnum &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||||
@ -119,6 +123,7 @@ namespace OpenAPI {
|
|||||||
bool fromJsonValue(float &value, const QJsonValue &jval);
|
bool fromJsonValue(float &value, const QJsonValue &jval);
|
||||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||||
bool fromJsonValue(OAIObject &value, const QJsonValue &jval);
|
bool fromJsonValue(OAIObject &value, const QJsonValue &jval);
|
||||||
|
bool fromJsonValue(OAIEnum &value, const QJsonValue &jval);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||||
|
@ -37,19 +37,25 @@ OAIOrder::~OAIOrder() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIOrder::init() {
|
OAIOrder::init() {
|
||||||
|
|
||||||
m_id_isSet = false;
|
m_id_isSet = false;
|
||||||
m_id_isValid = false;
|
m_id_isValid = false;
|
||||||
|
|
||||||
m_pet_id_isSet = false;
|
m_pet_id_isSet = false;
|
||||||
m_pet_id_isValid = false;
|
m_pet_id_isValid = false;
|
||||||
|
|
||||||
m_quantity_isSet = false;
|
m_quantity_isSet = false;
|
||||||
m_quantity_isValid = false;
|
m_quantity_isValid = false;
|
||||||
|
|
||||||
m_ship_date_isSet = false;
|
m_ship_date_isSet = false;
|
||||||
m_ship_date_isValid = false;
|
m_ship_date_isValid = false;
|
||||||
|
|
||||||
m_status_isSet = false;
|
m_status_isSet = false;
|
||||||
m_status_isValid = false;
|
m_status_isValid = false;
|
||||||
|
|
||||||
m_complete_isSet = false;
|
m_complete_isSet = false;
|
||||||
m_complete_isValid = false;
|
m_complete_isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OAIOrder::fromJson(QString jsonString) {
|
OAIOrder::fromJson(QString jsonString) {
|
||||||
@ -61,18 +67,25 @@ OAIOrder::fromJson(QString jsonString) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIOrder::fromJsonObject(QJsonObject json) {
|
OAIOrder::fromJsonObject(QJsonObject json) {
|
||||||
|
|
||||||
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||||
|
|
||||||
|
|
||||||
m_pet_id_isValid = ::OpenAPI::fromJsonValue(pet_id, json[QString("petId")]);
|
m_pet_id_isValid = ::OpenAPI::fromJsonValue(pet_id, json[QString("petId")]);
|
||||||
|
|
||||||
|
|
||||||
m_quantity_isValid = ::OpenAPI::fromJsonValue(quantity, json[QString("quantity")]);
|
m_quantity_isValid = ::OpenAPI::fromJsonValue(quantity, json[QString("quantity")]);
|
||||||
|
|
||||||
|
|
||||||
m_ship_date_isValid = ::OpenAPI::fromJsonValue(ship_date, json[QString("shipDate")]);
|
m_ship_date_isValid = ::OpenAPI::fromJsonValue(ship_date, json[QString("shipDate")]);
|
||||||
|
|
||||||
|
|
||||||
m_status_isValid = ::OpenAPI::fromJsonValue(status, json[QString("status")]);
|
m_status_isValid = ::OpenAPI::fromJsonValue(status, json[QString("status")]);
|
||||||
|
|
||||||
|
|
||||||
m_complete_isValid = ::OpenAPI::fromJsonValue(complete, json[QString("complete")]);
|
m_complete_isValid = ::OpenAPI::fromJsonValue(complete, json[QString("complete")]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -107,6 +120,7 @@ OAIOrder::asJsonObject() const {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint64
|
qint64
|
||||||
OAIOrder::getId() const {
|
OAIOrder::getId() const {
|
||||||
return id;
|
return id;
|
||||||
@ -117,6 +131,7 @@ OAIOrder::setId(const qint64 &id) {
|
|||||||
this->m_id_isSet = true;
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint64
|
qint64
|
||||||
OAIOrder::getPetId() const {
|
OAIOrder::getPetId() const {
|
||||||
return pet_id;
|
return pet_id;
|
||||||
@ -127,6 +142,7 @@ OAIOrder::setPetId(const qint64 &pet_id) {
|
|||||||
this->m_pet_id_isSet = true;
|
this->m_pet_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
OAIOrder::getQuantity() const {
|
OAIOrder::getQuantity() const {
|
||||||
return quantity;
|
return quantity;
|
||||||
@ -137,6 +153,7 @@ OAIOrder::setQuantity(const qint32 &quantity) {
|
|||||||
this->m_quantity_isSet = true;
|
this->m_quantity_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDateTime
|
QDateTime
|
||||||
OAIOrder::getShipDate() const {
|
OAIOrder::getShipDate() const {
|
||||||
return ship_date;
|
return ship_date;
|
||||||
@ -147,6 +164,7 @@ OAIOrder::setShipDate(const QDateTime &ship_date) {
|
|||||||
this->m_ship_date_isSet = true;
|
this->m_ship_date_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIOrder::getStatus() const {
|
OAIOrder::getStatus() const {
|
||||||
return status;
|
return status;
|
||||||
@ -157,6 +175,7 @@ OAIOrder::setStatus(const QString &status) {
|
|||||||
this->m_status_isSet = true;
|
this->m_status_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
OAIOrder::isComplete() const {
|
OAIOrder::isComplete() const {
|
||||||
return complete;
|
return complete;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "OAIObject.h"
|
#include "OAIObject.h"
|
||||||
|
#include "OAIEnum.h"
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -40,48 +41,63 @@ public:
|
|||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJsonObject(QJsonObject json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
|
|
||||||
qint64 getId() const;
|
qint64 getId() const;
|
||||||
void setId(const qint64 &id);
|
void setId(const qint64 &id);
|
||||||
|
|
||||||
|
|
||||||
qint64 getPetId() const;
|
qint64 getPetId() const;
|
||||||
void setPetId(const qint64 &pet_id);
|
void setPetId(const qint64 &pet_id);
|
||||||
|
|
||||||
|
|
||||||
qint32 getQuantity() const;
|
qint32 getQuantity() const;
|
||||||
void setQuantity(const qint32 &quantity);
|
void setQuantity(const qint32 &quantity);
|
||||||
|
|
||||||
|
|
||||||
QDateTime getShipDate() const;
|
QDateTime getShipDate() const;
|
||||||
void setShipDate(const QDateTime &ship_date);
|
void setShipDate(const QDateTime &ship_date);
|
||||||
|
|
||||||
|
|
||||||
QString getStatus() const;
|
QString getStatus() const;
|
||||||
void setStatus(const QString &status);
|
void setStatus(const QString &status);
|
||||||
|
|
||||||
|
|
||||||
bool isComplete() const;
|
bool isComplete() const;
|
||||||
void setComplete(const bool &complete);
|
void setComplete(const bool &complete);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
qint64 id;
|
qint64 id;
|
||||||
bool m_id_isSet;
|
bool m_id_isSet;
|
||||||
bool m_id_isValid;
|
bool m_id_isValid;
|
||||||
|
|
||||||
qint64 pet_id;
|
qint64 pet_id;
|
||||||
bool m_pet_id_isSet;
|
bool m_pet_id_isSet;
|
||||||
bool m_pet_id_isValid;
|
bool m_pet_id_isValid;
|
||||||
|
|
||||||
qint32 quantity;
|
qint32 quantity;
|
||||||
bool m_quantity_isSet;
|
bool m_quantity_isSet;
|
||||||
bool m_quantity_isValid;
|
bool m_quantity_isValid;
|
||||||
|
|
||||||
QDateTime ship_date;
|
QDateTime ship_date;
|
||||||
bool m_ship_date_isSet;
|
bool m_ship_date_isSet;
|
||||||
bool m_ship_date_isValid;
|
bool m_ship_date_isValid;
|
||||||
|
|
||||||
QString status;
|
QString status;
|
||||||
bool m_status_isSet;
|
bool m_status_isSet;
|
||||||
bool m_status_isValid;
|
bool m_status_isValid;
|
||||||
|
|
||||||
bool complete;
|
bool complete;
|
||||||
bool m_complete_isSet;
|
bool m_complete_isSet;
|
||||||
bool m_complete_isValid;
|
bool m_complete_isValid;
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,19 +37,25 @@ OAIPet::~OAIPet() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIPet::init() {
|
OAIPet::init() {
|
||||||
|
|
||||||
m_id_isSet = false;
|
m_id_isSet = false;
|
||||||
m_id_isValid = false;
|
m_id_isValid = false;
|
||||||
|
|
||||||
m_category_isSet = false;
|
m_category_isSet = false;
|
||||||
m_category_isValid = false;
|
m_category_isValid = false;
|
||||||
|
|
||||||
m_name_isSet = false;
|
m_name_isSet = false;
|
||||||
m_name_isValid = false;
|
m_name_isValid = false;
|
||||||
|
|
||||||
m_photo_urls_isSet = false;
|
m_photo_urls_isSet = false;
|
||||||
m_photo_urls_isValid = false;
|
m_photo_urls_isValid = false;
|
||||||
|
|
||||||
m_tags_isSet = false;
|
m_tags_isSet = false;
|
||||||
m_tags_isValid = false;
|
m_tags_isValid = false;
|
||||||
|
|
||||||
m_status_isSet = false;
|
m_status_isSet = false;
|
||||||
m_status_isValid = false;
|
m_status_isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OAIPet::fromJson(QString jsonString) {
|
OAIPet::fromJson(QString jsonString) {
|
||||||
@ -61,18 +67,25 @@ OAIPet::fromJson(QString jsonString) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIPet::fromJsonObject(QJsonObject json) {
|
OAIPet::fromJsonObject(QJsonObject json) {
|
||||||
|
|
||||||
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||||
|
|
||||||
|
|
||||||
m_category_isValid = ::OpenAPI::fromJsonValue(category, json[QString("category")]);
|
m_category_isValid = ::OpenAPI::fromJsonValue(category, json[QString("category")]);
|
||||||
|
|
||||||
|
|
||||||
m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_photo_urls_isValid = ::OpenAPI::fromJsonValue(photo_urls, json[QString("photoUrls")]);
|
m_photo_urls_isValid = ::OpenAPI::fromJsonValue(photo_urls, json[QString("photoUrls")]);
|
||||||
|
|
||||||
|
|
||||||
m_tags_isValid = ::OpenAPI::fromJsonValue(tags, json[QString("tags")]);
|
m_tags_isValid = ::OpenAPI::fromJsonValue(tags, json[QString("tags")]);
|
||||||
|
|
||||||
m_status_isValid = ::OpenAPI::fromJsonValue(status, json[QString("status")]);
|
m_status_isValid = ::OpenAPI::fromJsonValue(status, json[QString("status")]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -109,6 +122,7 @@ OAIPet::asJsonObject() const {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint64
|
qint64
|
||||||
OAIPet::getId() const {
|
OAIPet::getId() const {
|
||||||
return id;
|
return id;
|
||||||
@ -119,6 +133,7 @@ OAIPet::setId(const qint64 &id) {
|
|||||||
this->m_id_isSet = true;
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OAICategory
|
OAICategory
|
||||||
OAIPet::getCategory() const {
|
OAIPet::getCategory() const {
|
||||||
return category;
|
return category;
|
||||||
@ -129,6 +144,7 @@ OAIPet::setCategory(const OAICategory &category) {
|
|||||||
this->m_category_isSet = true;
|
this->m_category_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIPet::getName() const {
|
OAIPet::getName() const {
|
||||||
return name;
|
return name;
|
||||||
@ -139,6 +155,7 @@ OAIPet::setName(const QString &name) {
|
|||||||
this->m_name_isSet = true;
|
this->m_name_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QString>
|
QList<QString>
|
||||||
OAIPet::getPhotoUrls() const {
|
OAIPet::getPhotoUrls() const {
|
||||||
return photo_urls;
|
return photo_urls;
|
||||||
@ -149,6 +166,7 @@ OAIPet::setPhotoUrls(const QList<QString> &photo_urls) {
|
|||||||
this->m_photo_urls_isSet = true;
|
this->m_photo_urls_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<OAITag>
|
QList<OAITag>
|
||||||
OAIPet::getTags() const {
|
OAIPet::getTags() const {
|
||||||
return tags;
|
return tags;
|
||||||
@ -159,6 +177,7 @@ OAIPet::setTags(const QList<OAITag> &tags) {
|
|||||||
this->m_tags_isSet = true;
|
this->m_tags_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIPet::getStatus() const {
|
OAIPet::getStatus() const {
|
||||||
return status;
|
return status;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "OAIObject.h"
|
#include "OAIObject.h"
|
||||||
|
#include "OAIEnum.h"
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -42,48 +43,63 @@ public:
|
|||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJsonObject(QJsonObject json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
|
|
||||||
qint64 getId() const;
|
qint64 getId() const;
|
||||||
void setId(const qint64 &id);
|
void setId(const qint64 &id);
|
||||||
|
|
||||||
|
|
||||||
OAICategory getCategory() const;
|
OAICategory getCategory() const;
|
||||||
void setCategory(const OAICategory &category);
|
void setCategory(const OAICategory &category);
|
||||||
|
|
||||||
|
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
|
||||||
QList<QString> getPhotoUrls() const;
|
QList<QString> getPhotoUrls() const;
|
||||||
void setPhotoUrls(const QList<QString> &photo_urls);
|
void setPhotoUrls(const QList<QString> &photo_urls);
|
||||||
|
|
||||||
|
|
||||||
QList<OAITag> getTags() const;
|
QList<OAITag> getTags() const;
|
||||||
void setTags(const QList<OAITag> &tags);
|
void setTags(const QList<OAITag> &tags);
|
||||||
|
|
||||||
|
|
||||||
QString getStatus() const;
|
QString getStatus() const;
|
||||||
void setStatus(const QString &status);
|
void setStatus(const QString &status);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
qint64 id;
|
qint64 id;
|
||||||
bool m_id_isSet;
|
bool m_id_isSet;
|
||||||
bool m_id_isValid;
|
bool m_id_isValid;
|
||||||
|
|
||||||
OAICategory category;
|
OAICategory category;
|
||||||
bool m_category_isSet;
|
bool m_category_isSet;
|
||||||
bool m_category_isValid;
|
bool m_category_isValid;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
bool m_name_isSet;
|
bool m_name_isSet;
|
||||||
bool m_name_isValid;
|
bool m_name_isValid;
|
||||||
|
|
||||||
QList<QString> photo_urls;
|
QList<QString> photo_urls;
|
||||||
bool m_photo_urls_isSet;
|
bool m_photo_urls_isSet;
|
||||||
bool m_photo_urls_isValid;
|
bool m_photo_urls_isValid;
|
||||||
|
|
||||||
QList<OAITag> tags;
|
QList<OAITag> tags;
|
||||||
bool m_tags_isSet;
|
bool m_tags_isSet;
|
||||||
bool m_tags_isValid;
|
bool m_tags_isValid;
|
||||||
|
|
||||||
QString status;
|
QString status;
|
||||||
bool m_status_isSet;
|
bool m_status_isSet;
|
||||||
bool m_status_isValid;
|
bool m_status_isValid;
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,11 +37,13 @@ OAITag::~OAITag() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAITag::init() {
|
OAITag::init() {
|
||||||
|
|
||||||
m_id_isSet = false;
|
m_id_isSet = false;
|
||||||
m_id_isValid = false;
|
m_id_isValid = false;
|
||||||
|
|
||||||
m_name_isSet = false;
|
m_name_isSet = false;
|
||||||
m_name_isValid = false;
|
m_name_isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OAITag::fromJson(QString jsonString) {
|
OAITag::fromJson(QString jsonString) {
|
||||||
@ -53,10 +55,13 @@ OAITag::fromJson(QString jsonString) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAITag::fromJsonObject(QJsonObject json) {
|
OAITag::fromJsonObject(QJsonObject json) {
|
||||||
|
|
||||||
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||||
|
|
||||||
|
|
||||||
m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -79,6 +84,7 @@ OAITag::asJsonObject() const {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint64
|
qint64
|
||||||
OAITag::getId() const {
|
OAITag::getId() const {
|
||||||
return id;
|
return id;
|
||||||
@ -89,6 +95,7 @@ OAITag::setId(const qint64 &id) {
|
|||||||
this->m_id_isSet = true;
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAITag::getName() const {
|
OAITag::getName() const {
|
||||||
return name;
|
return name;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "OAIObject.h"
|
#include "OAIObject.h"
|
||||||
|
#include "OAIEnum.h"
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -39,24 +40,31 @@ public:
|
|||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJsonObject(QJsonObject json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
|
|
||||||
qint64 getId() const;
|
qint64 getId() const;
|
||||||
void setId(const qint64 &id);
|
void setId(const qint64 &id);
|
||||||
|
|
||||||
|
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
qint64 id;
|
qint64 id;
|
||||||
bool m_id_isSet;
|
bool m_id_isSet;
|
||||||
bool m_id_isValid;
|
bool m_id_isValid;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
bool m_name_isSet;
|
bool m_name_isSet;
|
||||||
bool m_name_isValid;
|
bool m_name_isValid;
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,23 +37,31 @@ OAIUser::~OAIUser() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIUser::init() {
|
OAIUser::init() {
|
||||||
|
|
||||||
m_id_isSet = false;
|
m_id_isSet = false;
|
||||||
m_id_isValid = false;
|
m_id_isValid = false;
|
||||||
|
|
||||||
m_username_isSet = false;
|
m_username_isSet = false;
|
||||||
m_username_isValid = false;
|
m_username_isValid = false;
|
||||||
|
|
||||||
m_first_name_isSet = false;
|
m_first_name_isSet = false;
|
||||||
m_first_name_isValid = false;
|
m_first_name_isValid = false;
|
||||||
|
|
||||||
m_last_name_isSet = false;
|
m_last_name_isSet = false;
|
||||||
m_last_name_isValid = false;
|
m_last_name_isValid = false;
|
||||||
|
|
||||||
m_email_isSet = false;
|
m_email_isSet = false;
|
||||||
m_email_isValid = false;
|
m_email_isValid = false;
|
||||||
|
|
||||||
m_password_isSet = false;
|
m_password_isSet = false;
|
||||||
m_password_isValid = false;
|
m_password_isValid = false;
|
||||||
|
|
||||||
m_phone_isSet = false;
|
m_phone_isSet = false;
|
||||||
m_phone_isValid = false;
|
m_phone_isValid = false;
|
||||||
|
|
||||||
m_user_status_isSet = false;
|
m_user_status_isSet = false;
|
||||||
m_user_status_isValid = false;
|
m_user_status_isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OAIUser::fromJson(QString jsonString) {
|
OAIUser::fromJson(QString jsonString) {
|
||||||
@ -65,22 +73,31 @@ OAIUser::fromJson(QString jsonString) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
OAIUser::fromJsonObject(QJsonObject json) {
|
OAIUser::fromJsonObject(QJsonObject json) {
|
||||||
|
|
||||||
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||||
|
|
||||||
|
|
||||||
m_username_isValid = ::OpenAPI::fromJsonValue(username, json[QString("username")]);
|
m_username_isValid = ::OpenAPI::fromJsonValue(username, json[QString("username")]);
|
||||||
|
|
||||||
|
|
||||||
m_first_name_isValid = ::OpenAPI::fromJsonValue(first_name, json[QString("firstName")]);
|
m_first_name_isValid = ::OpenAPI::fromJsonValue(first_name, json[QString("firstName")]);
|
||||||
|
|
||||||
|
|
||||||
m_last_name_isValid = ::OpenAPI::fromJsonValue(last_name, json[QString("lastName")]);
|
m_last_name_isValid = ::OpenAPI::fromJsonValue(last_name, json[QString("lastName")]);
|
||||||
|
|
||||||
|
|
||||||
m_email_isValid = ::OpenAPI::fromJsonValue(email, json[QString("email")]);
|
m_email_isValid = ::OpenAPI::fromJsonValue(email, json[QString("email")]);
|
||||||
|
|
||||||
|
|
||||||
m_password_isValid = ::OpenAPI::fromJsonValue(password, json[QString("password")]);
|
m_password_isValid = ::OpenAPI::fromJsonValue(password, json[QString("password")]);
|
||||||
|
|
||||||
|
|
||||||
m_phone_isValid = ::OpenAPI::fromJsonValue(phone, json[QString("phone")]);
|
m_phone_isValid = ::OpenAPI::fromJsonValue(phone, json[QString("phone")]);
|
||||||
|
|
||||||
|
|
||||||
m_user_status_isValid = ::OpenAPI::fromJsonValue(user_status, json[QString("userStatus")]);
|
m_user_status_isValid = ::OpenAPI::fromJsonValue(user_status, json[QString("userStatus")]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -121,6 +138,7 @@ OAIUser::asJsonObject() const {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint64
|
qint64
|
||||||
OAIUser::getId() const {
|
OAIUser::getId() const {
|
||||||
return id;
|
return id;
|
||||||
@ -131,6 +149,7 @@ OAIUser::setId(const qint64 &id) {
|
|||||||
this->m_id_isSet = true;
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIUser::getUsername() const {
|
OAIUser::getUsername() const {
|
||||||
return username;
|
return username;
|
||||||
@ -141,6 +160,7 @@ OAIUser::setUsername(const QString &username) {
|
|||||||
this->m_username_isSet = true;
|
this->m_username_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIUser::getFirstName() const {
|
OAIUser::getFirstName() const {
|
||||||
return first_name;
|
return first_name;
|
||||||
@ -151,6 +171,7 @@ OAIUser::setFirstName(const QString &first_name) {
|
|||||||
this->m_first_name_isSet = true;
|
this->m_first_name_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIUser::getLastName() const {
|
OAIUser::getLastName() const {
|
||||||
return last_name;
|
return last_name;
|
||||||
@ -161,6 +182,7 @@ OAIUser::setLastName(const QString &last_name) {
|
|||||||
this->m_last_name_isSet = true;
|
this->m_last_name_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIUser::getEmail() const {
|
OAIUser::getEmail() const {
|
||||||
return email;
|
return email;
|
||||||
@ -171,6 +193,7 @@ OAIUser::setEmail(const QString &email) {
|
|||||||
this->m_email_isSet = true;
|
this->m_email_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIUser::getPassword() const {
|
OAIUser::getPassword() const {
|
||||||
return password;
|
return password;
|
||||||
@ -181,6 +204,7 @@ OAIUser::setPassword(const QString &password) {
|
|||||||
this->m_password_isSet = true;
|
this->m_password_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
OAIUser::getPhone() const {
|
OAIUser::getPhone() const {
|
||||||
return phone;
|
return phone;
|
||||||
@ -191,6 +215,7 @@ OAIUser::setPhone(const QString &phone) {
|
|||||||
this->m_phone_isSet = true;
|
this->m_phone_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
OAIUser::getUserStatus() const {
|
OAIUser::getUserStatus() const {
|
||||||
return user_status;
|
return user_status;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "OAIObject.h"
|
#include "OAIObject.h"
|
||||||
|
#include "OAIEnum.h"
|
||||||
|
|
||||||
namespace OpenAPI {
|
namespace OpenAPI {
|
||||||
|
|
||||||
@ -39,60 +40,79 @@ public:
|
|||||||
void fromJsonObject(QJsonObject json) override;
|
void fromJsonObject(QJsonObject json) override;
|
||||||
void fromJson(QString jsonString) override;
|
void fromJson(QString jsonString) override;
|
||||||
|
|
||||||
|
|
||||||
qint64 getId() const;
|
qint64 getId() const;
|
||||||
void setId(const qint64 &id);
|
void setId(const qint64 &id);
|
||||||
|
|
||||||
|
|
||||||
QString getUsername() const;
|
QString getUsername() const;
|
||||||
void setUsername(const QString &username);
|
void setUsername(const QString &username);
|
||||||
|
|
||||||
|
|
||||||
QString getFirstName() const;
|
QString getFirstName() const;
|
||||||
void setFirstName(const QString &first_name);
|
void setFirstName(const QString &first_name);
|
||||||
|
|
||||||
|
|
||||||
QString getLastName() const;
|
QString getLastName() const;
|
||||||
void setLastName(const QString &last_name);
|
void setLastName(const QString &last_name);
|
||||||
|
|
||||||
|
|
||||||
QString getEmail() const;
|
QString getEmail() const;
|
||||||
void setEmail(const QString &email);
|
void setEmail(const QString &email);
|
||||||
|
|
||||||
|
|
||||||
QString getPassword() const;
|
QString getPassword() const;
|
||||||
void setPassword(const QString &password);
|
void setPassword(const QString &password);
|
||||||
|
|
||||||
|
|
||||||
QString getPhone() const;
|
QString getPhone() const;
|
||||||
void setPhone(const QString &phone);
|
void setPhone(const QString &phone);
|
||||||
|
|
||||||
|
|
||||||
qint32 getUserStatus() const;
|
qint32 getUserStatus() const;
|
||||||
void setUserStatus(const qint32 &user_status);
|
void setUserStatus(const qint32 &user_status);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool isSet() const override;
|
virtual bool isSet() const override;
|
||||||
virtual bool isValid() const override;
|
virtual bool isValid() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
qint64 id;
|
qint64 id;
|
||||||
bool m_id_isSet;
|
bool m_id_isSet;
|
||||||
bool m_id_isValid;
|
bool m_id_isValid;
|
||||||
|
|
||||||
QString username;
|
QString username;
|
||||||
bool m_username_isSet;
|
bool m_username_isSet;
|
||||||
bool m_username_isValid;
|
bool m_username_isValid;
|
||||||
|
|
||||||
QString first_name;
|
QString first_name;
|
||||||
bool m_first_name_isSet;
|
bool m_first_name_isSet;
|
||||||
bool m_first_name_isValid;
|
bool m_first_name_isValid;
|
||||||
|
|
||||||
QString last_name;
|
QString last_name;
|
||||||
bool m_last_name_isSet;
|
bool m_last_name_isSet;
|
||||||
bool m_last_name_isValid;
|
bool m_last_name_isValid;
|
||||||
|
|
||||||
QString email;
|
QString email;
|
||||||
bool m_email_isSet;
|
bool m_email_isSet;
|
||||||
bool m_email_isValid;
|
bool m_email_isValid;
|
||||||
|
|
||||||
QString password;
|
QString password;
|
||||||
bool m_password_isSet;
|
bool m_password_isSet;
|
||||||
bool m_password_isValid;
|
bool m_password_isValid;
|
||||||
|
|
||||||
QString phone;
|
QString phone;
|
||||||
bool m_phone_isSet;
|
bool m_phone_isSet;
|
||||||
bool m_phone_isValid;
|
bool m_phone_isValid;
|
||||||
|
|
||||||
qint32 user_status;
|
qint32 user_status;
|
||||||
bool m_user_status_isSet;
|
bool m_user_status_isSet;
|
||||||
bool m_user_status_isValid;
|
bool m_user_status_isValid;
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ HEADERS += \
|
|||||||
$${PWD}/OAIHelpers.h \
|
$${PWD}/OAIHelpers.h \
|
||||||
$${PWD}/OAIHttpRequest.h \
|
$${PWD}/OAIHttpRequest.h \
|
||||||
$${PWD}/OAIObject.h
|
$${PWD}/OAIObject.h
|
||||||
|
$${PWD}/OAIEnum.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
# Models
|
# Models
|
||||||
|
Loading…
x
Reference in New Issue
Block a user