mirror of
				https://github.com/OpenAPITools/openapi-generator.git
				synced 2025-11-04 10:43:44 +00:00 
			
		
		
		
	Qt5cpp plug memleaks (#7695)
* Small fixes to prevent crash when empty json body is provided. * WIP: plug mem-leaks * fixup: add the QJsonObject instance in toJsonArray instead of pointer * fixup: simplify toJsonMap Actually the original solution is incomplete, because "innerType" maps to a single C++ type. Have a look at Qt's builtin QJsonObject::fromVariantMap. * Updates to antis81:patch-1 after tests. * update to remove string allocation * Updates due to address of members being passed * Update PetStore Examples * Small updates for Header includes
This commit is contained in:
		
							parent
							
								
									d5f3619199
								
							
						
					
					
						commit
						12f3661d6f
					
				@ -47,7 +47,7 @@ void {{prefix}}HttpRequestInput::add_file(QString variable_name, QString local_f
 | 
			
		||||
    qsrand(QDateTime::currentDateTime().toTime_t());
 | 
			
		||||
 | 
			
		||||
    manager = new QNetworkAccessManager(this);
 | 
			
		||||
    connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_manager_finished(QNetworkReply*)));
 | 
			
		||||
    connect(manager, &QNetworkAccessManager::finished, this, &{{prefix}}HttpRequestWorker::on_manager_finished);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
{{prefix}}HttpRequestWorker::~{{prefix}}HttpRequestWorker() {
 | 
			
		||||
 | 
			
		||||
@ -98,10 +98,10 @@ void
 | 
			
		||||
 | 
			
		||||
    {{#bodyParams}}
 | 
			
		||||
    {{#isContainer}}
 | 
			
		||||
    auto {{paramName}}_jobj = new QJsonObject();
 | 
			
		||||
    QJsonObject {{paramName}}_jobj;
 | 
			
		||||
    toJsonArray((QList<void*>*){{paramName}}, {{paramName}}_jobj, QString("body"), QString("{{prefix}}User*"));
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*{{paramName}}_jobj);
 | 
			
		||||
    QJsonDocument doc({{paramName}}_jobj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
 | 
			
		||||
    input.request_body.append(bytes);
 | 
			
		||||
@ -175,7 +175,7 @@ void
 | 
			
		||||
 | 
			
		||||
    foreach(QString key, obj.keys()) {
 | 
			
		||||
        qint32* val;
 | 
			
		||||
        setValue(&val, obj[key], "{{returnBaseType}}", "");
 | 
			
		||||
        setValue(&val, obj[key], "{{returnBaseType}}", QString());
 | 
			
		||||
        output->insert(key, *val);
 | 
			
		||||
    }
 | 
			
		||||
    {{/isMapContainer}}
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("float").compare(type) == 0) {
 | 
			
		||||
        float *val = static_cast<float*>(value);
 | 
			
		||||
        *val = obj.toDouble();
 | 
			
		||||
        *val = static_cast<float>(obj.toDouble());
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("double").compare(type) == 0) {
 | 
			
		||||
        double *val = static_cast<double*>(value);
 | 
			
		||||
@ -42,20 +42,14 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
 | 
			
		||||
        QString **val = static_cast<QString**>(value);
 | 
			
		||||
        if(val != nullptr) {
 | 
			
		||||
            if(!obj.isNull()) {
 | 
			
		||||
                // create a new value and return
 | 
			
		||||
                if(*val != nullptr) delete *val;
 | 
			
		||||
                *val = new QString(obj.toString());
 | 
			
		||||
                (*val)->clear();
 | 
			
		||||
                (*val)->append(obj.toString());
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                // set target to nullptr
 | 
			
		||||
                if(*val != nullptr) delete *val;
 | 
			
		||||
                *val = nullptr;
 | 
			
		||||
                (*val)->clear();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            qDebug() << "Can't set value because the target pointer is nullptr";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if (QStringLiteral("QDateTime").compare(type) == 0) {
 | 
			
		||||
        QDateTime **val = static_cast<QDateTime**>(value);
 | 
			
		||||
@ -371,67 +365,66 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
 | 
			
		||||
toJsonValue(QString name, void* value, QJsonObject& output, QString type) {
 | 
			
		||||
    if(value == nullptr) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    if(type.startsWith("{{prefix}}")) {
 | 
			
		||||
        {{prefix}}Object *{{prefix}}object = reinterpret_cast<{{prefix}}Object *>(value);
 | 
			
		||||
        if({{prefix}}object != nullptr) {
 | 
			
		||||
            QJsonObject* o = (*{{prefix}}object).asJsonObject();
 | 
			
		||||
            if(name != nullptr) {
 | 
			
		||||
                output->insert(name, *o);
 | 
			
		||||
                if(o != nullptr) delete o;
 | 
			
		||||
            QJsonObject o = {{prefix}}object->asJsonObject();
 | 
			
		||||
            if(!name.isNull()) {
 | 
			
		||||
                output.insert(name, o);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                output->empty();
 | 
			
		||||
                for(QString key : o->keys()) {
 | 
			
		||||
                    output->insert(key, o->value(key));
 | 
			
		||||
                output.empty();
 | 
			
		||||
                for(QString key : o.keys()) {
 | 
			
		||||
                    output.insert(key, o.value(key));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QString").compare(type) == 0) {
 | 
			
		||||
        QString* str = static_cast<QString*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint32").compare(type) == 0) {
 | 
			
		||||
        qint32* str = static_cast<qint32*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint64").compare(type) == 0) {
 | 
			
		||||
        qint64* str = static_cast<qint64*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("bool").compare(type) == 0) {
 | 
			
		||||
        bool* str = static_cast<bool*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("float").compare(type) == 0) {
 | 
			
		||||
        float* str = static_cast<float*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue((double)*str));
 | 
			
		||||
        output.insert(name, QJsonValue((double)*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("double").compare(type) == 0) {
 | 
			
		||||
        double* str = static_cast<double*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDate").compare(type) == 0) {
 | 
			
		||||
        QDate* date = static_cast<QDate*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(date->toString(Qt::ISODate)));
 | 
			
		||||
        output.insert(name, QJsonValue(date->toString(Qt::ISODate)));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDateTime").compare(type) == 0) {
 | 
			
		||||
        QDateTime* datetime = static_cast<QDateTime*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(datetime->toString(Qt::ISODate)));
 | 
			
		||||
        output.insert(name, QJsonValue(datetime->toString(Qt::ISODate)));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QByteArray").compare(type) == 0) {
 | 
			
		||||
        QByteArray* byteArray = static_cast<QByteArray*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(QString(byteArray->toBase64())));
 | 
			
		||||
        output.insert(name, QJsonValue(QString(byteArray->toBase64())));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString innerType) {
 | 
			
		||||
    if((value == nullptr) || (output == nullptr)) {
 | 
			
		||||
toJsonArray(QList<void*>* value, QJsonObject& output, QString innerName, QString innerType) {
 | 
			
		||||
    if(value == nullptr) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    QJsonArray outputarray;
 | 
			
		||||
@ -439,7 +432,7 @@ toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString
 | 
			
		||||
        for(void* obj : *value) {
 | 
			
		||||
            {{prefix}}Object *{{prefix}}object = reinterpret_cast<{{prefix}}Object *>(obj);
 | 
			
		||||
            if({{prefix}}object != nullptr) {
 | 
			
		||||
                outputarray.append(*({{prefix}}object->asJsonObject()));
 | 
			
		||||
                outputarray.append({{prefix}}object->asJsonObject());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -482,81 +475,81 @@ toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString
 | 
			
		||||
        for(double obj : *(reinterpret_cast<QList<double>*>(value)))
 | 
			
		||||
            outputarray.append(QJsonValue(obj));
 | 
			
		||||
    }
 | 
			
		||||
    output->insert(innerName, outputarray);
 | 
			
		||||
    output.insert(innerName, outputarray);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
toJsonMap(QMap<QString, void*>* value, QJsonObject* output, QString innerName, QString innerType) {
 | 
			
		||||
    if((value == nullptr) || (output == nullptr)) {
 | 
			
		||||
toJsonMap(QMap<QString, void*>* value, QJsonObject& output, QString innerName, QString innerType) {
 | 
			
		||||
    if(value == nullptr)  {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    QJsonObject mapobj;
 | 
			
		||||
    if(innerType.startsWith("{{prefix}}")){
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, {{prefix}}Object*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey),mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QString").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QString*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDate").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QDate*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDateTime").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QDateTime*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QByteArray").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QByteArray*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint32").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, qint32> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint64").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, qint64> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("bool").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, bool> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("float").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, float> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("double").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, double> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys() ) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::{{cppNamespace}}::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    output->insert(innerName, mapobj);
 | 
			
		||||
    output.insert(innerName, mapobj);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString
 | 
			
		||||
@ -582,4 +575,4 @@ stringValue(bool value) {
 | 
			
		||||
 | 
			
		||||
{{#cppNamespaceDeclarations}}
 | 
			
		||||
}
 | 
			
		||||
{{/cppNamespaceDeclarations}}
 | 
			
		||||
{{/cppNamespaceDeclarations}}
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
#ifndef {{prefix}}_HELPERS_H
 | 
			
		||||
#define {{prefix}}_HELPERS_H
 | 
			
		||||
 | 
			
		||||
#include <QJsonObject>
 | 
			
		||||
#include <QJsonValue>
 | 
			
		||||
#include <QList>
 | 
			
		||||
#include <QMap>
 | 
			
		||||
@ -11,9 +12,9 @@ namespace {{this}} {
 | 
			
		||||
{{/cppNamespaceDeclarations}}
 | 
			
		||||
 | 
			
		||||
    void setValue(void* value, QJsonValue obj, QString type, QString complexType);
 | 
			
		||||
    void toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString innerType);
 | 
			
		||||
    void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
 | 
			
		||||
    void toJsonMap(QMap<QString, void*>* value, QJsonObject* output, QString innerName, QString innerType);
 | 
			
		||||
    void toJsonArray(QList<void*>* value, QJsonObject& output, QString innerName, QString innerType);
 | 
			
		||||
    void toJsonValue(QString name, void* value, QJsonObject& output, QString type);
 | 
			
		||||
    void toJsonMap(QMap<QString, void*>* value, QJsonObject& output, QString innerName, QString innerType);
 | 
			
		||||
    bool isCompatibleJsonValue(QString type);
 | 
			
		||||
    QString stringValue(QString* value);
 | 
			
		||||
    QString stringValue(qint32 value);
 | 
			
		||||
 | 
			
		||||
@ -13,9 +13,9 @@
 | 
			
		||||
namespace {{this}} {
 | 
			
		||||
{{/cppNamespaceDeclarations}}
 | 
			
		||||
 | 
			
		||||
{{classname}}::{{classname}}(QString* json) {
 | 
			
		||||
{{classname}}::{{classname}}(QString json) {
 | 
			
		||||
    init();
 | 
			
		||||
    this->fromJson(*json);
 | 
			
		||||
    this->fromJson(json);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
{{classname}}::{{classname}}() {
 | 
			
		||||
@ -52,7 +52,7 @@ void
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
{{classname}}*
 | 
			
		||||
{{classname}}::fromJson(QString &json) {
 | 
			
		||||
{{classname}}::fromJson(QString json) {
 | 
			
		||||
    QByteArray array (json.toStdString().c_str());
 | 
			
		||||
    QJsonDocument doc = QJsonDocument::fromJson(array);
 | 
			
		||||
    QJsonObject jsonObject = doc.object();
 | 
			
		||||
@ -61,7 +61,7 @@ void
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
{{classname}}::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
{{classname}}::fromJsonObject(QJsonObject pJson) {
 | 
			
		||||
    {{#vars}}
 | 
			
		||||
    {{^isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}}
 | 
			
		||||
    {{#isContainer}}{{^items.isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}");{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}}
 | 
			
		||||
@ -94,16 +94,15 @@ void
 | 
			
		||||
QString
 | 
			
		||||
{{classname}}::asJson ()
 | 
			
		||||
{
 | 
			
		||||
    QJsonObject* obj = this->asJsonObject();
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*obj);
 | 
			
		||||
    QJsonObject obj = this->asJsonObject();
 | 
			
		||||
    QJsonDocument doc(obj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
    return QString(bytes);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QJsonObject*
 | 
			
		||||
QJsonObject
 | 
			
		||||
{{classname}}::asJsonObject() {
 | 
			
		||||
    QJsonObject* obj = new QJsonObject();
 | 
			
		||||
    QJsonObject obj;
 | 
			
		||||
    {{#vars}}
 | 
			
		||||
    {{^isContainer}}
 | 
			
		||||
    {{#complexType}}
 | 
			
		||||
@ -129,7 +128,7 @@ QJsonObject*
 | 
			
		||||
    {{^isDate}}
 | 
			
		||||
    {{^isByteArray}}
 | 
			
		||||
    if(m_{{name}}_isSet){
 | 
			
		||||
        obj->insert("{{baseName}}", QJsonValue({{name}}));
 | 
			
		||||
        obj.insert("{{baseName}}", QJsonValue({{name}}));
 | 
			
		||||
    }
 | 
			
		||||
    {{/isByteArray}}
 | 
			
		||||
    {{/isDate}}
 | 
			
		||||
@ -142,7 +141,7 @@ QJsonObject*
 | 
			
		||||
    {{/isDate}}
 | 
			
		||||
    {{#isByteArray}}    
 | 
			
		||||
    if({{name}} != nullptr) { 
 | 
			
		||||
        obj->insert("{{name}}", QJsonValue(*{{name}}));
 | 
			
		||||
        obj.insert("{{name}}", QJsonValue(*{{name}}));
 | 
			
		||||
    }
 | 
			
		||||
    {{/isByteArray}}
 | 
			
		||||
    {{#isDateTime}}   
 | 
			
		||||
@ -162,14 +161,14 @@ QJsonObject*
 | 
			
		||||
        for(auto items : *{{name}}){
 | 
			
		||||
            QJsonObject jobj;
 | 
			
		||||
            {{#items.isListContainer}}
 | 
			
		||||
            toJsonArray((QList<void*>*)items, &jobj, "{{baseName}}", "{{items.items.baseType}}");
 | 
			
		||||
            toJsonArray((QList<void*>*)items, jobj, "{{baseName}}", "{{items.items.baseType}}");
 | 
			
		||||
            {{/items.isListContainer}}
 | 
			
		||||
            {{#items.isMapContainer}}
 | 
			
		||||
            toJsonMap((QMap<QString, void*>*)items, &jobj, "{{baseName}}", "{{items.items.baseType}}");
 | 
			
		||||
            toJsonMap((QMap<QString, void*>*)items, jobj, "{{baseName}}", "{{items.items.baseType}}");
 | 
			
		||||
            {{/items.isMapContainer}}
 | 
			
		||||
            jarray.append(jobj.value("{{baseName}}"));
 | 
			
		||||
        }
 | 
			
		||||
        obj->insert("{{baseName}}", jarray);
 | 
			
		||||
        obj.insert("{{baseName}}", jarray);
 | 
			
		||||
        {{/items.isContainer}}
 | 
			
		||||
    }
 | 
			
		||||
    {{/isListContainer}}
 | 
			
		||||
@ -180,14 +179,14 @@ QJsonObject*
 | 
			
		||||
        for(auto itemkey : {{name}}->keys()){
 | 
			
		||||
            QJsonObject jobj;
 | 
			
		||||
            {{#items.isListContainer}}
 | 
			
		||||
            toJsonArray((QList<void*>*){{name}}->value(itemkey), &jobj, itemkey, "{{items.items.baseType}}");
 | 
			
		||||
            toJsonArray((QList<void*>*){{name}}->value(itemkey), jobj, itemkey, "{{items.items.baseType}}");
 | 
			
		||||
            {{/items.isListContainer}}
 | 
			
		||||
            {{#items.isMapContainer}}
 | 
			
		||||
            toJsonMap((QMap<QString, void*>*){{name}}->value(itemkey), &jobj, itemkey, "{{items.items.baseType}}");
 | 
			
		||||
            toJsonMap((QMap<QString, void*>*){{name}}->value(itemkey), jobj, itemkey, "{{items.items.baseType}}");
 | 
			
		||||
            {{/items.isMapContainer}}
 | 
			
		||||
            mapobj.insert(itemkey, jobj);
 | 
			
		||||
        }
 | 
			
		||||
        obj->insert("{{baseName}}", mapobj);{{/items.isContainer}}
 | 
			
		||||
        obj.insert("{{baseName}}", mapobj);{{/items.isContainer}}
 | 
			
		||||
    }
 | 
			
		||||
    {{/isMapContainer}}
 | 
			
		||||
    {{/isContainer}}
 | 
			
		||||
 | 
			
		||||
@ -25,15 +25,15 @@ namespace {{this}} {
 | 
			
		||||
class {{classname}}: public {{prefix}}Object {
 | 
			
		||||
public:
 | 
			
		||||
    {{classname}}();
 | 
			
		||||
    {{classname}}(QString* json);
 | 
			
		||||
    virtual ~{{classname}}();
 | 
			
		||||
    {{classname}}(QString json);
 | 
			
		||||
    ~{{classname}}();
 | 
			
		||||
    void init();
 | 
			
		||||
    void cleanup();
 | 
			
		||||
 | 
			
		||||
    QString asJson ();
 | 
			
		||||
    QJsonObject* asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject &json);
 | 
			
		||||
    {{classname}}* fromJson(QString &jsonString);
 | 
			
		||||
    QJsonObject asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject json);
 | 
			
		||||
    {{classname}}* fromJson(QString jsonString);
 | 
			
		||||
 | 
			
		||||
    {{#vars}}
 | 
			
		||||
    {{{datatype}}} {{getter}}();
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
#ifndef ModelFactory_H_
 | 
			
		||||
#define ModelFactory_H_
 | 
			
		||||
 | 
			
		||||
#include "{{prefix}}Object.h"
 | 
			
		||||
{{#models}}{{#model}}
 | 
			
		||||
#include "{{classname}}.h"{{/model}}{{/models}}
 | 
			
		||||
 | 
			
		||||
@ -18,13 +19,12 @@ namespace {{this}} {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  inline void* create(QString json, QString type) {
 | 
			
		||||
    void* val = create(type);
 | 
			
		||||
    if(val != nullptr) {
 | 
			
		||||
      {{prefix}}Object* obj = static_cast<{{prefix}}Object*>(val);
 | 
			
		||||
      return obj->fromJson(json);
 | 
			
		||||
    }
 | 
			
		||||
    if(type.startsWith("QString")) {
 | 
			
		||||
      return new QString();
 | 
			
		||||
    }    
 | 
			
		||||
    auto val = static_cast<{{prefix}}Object*>(create(type));
 | 
			
		||||
    if(val != nullptr) {
 | 
			
		||||
      return val->fromJson(json);
 | 
			
		||||
    }
 | 
			
		||||
    return nullptr;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
#ifndef _{{prefix}}_OBJECT_H_
 | 
			
		||||
#define _{{prefix}}_OBJECT_H_
 | 
			
		||||
 | 
			
		||||
#include <QJsonValue>
 | 
			
		||||
#include <QJsonObject>
 | 
			
		||||
 | 
			
		||||
{{#cppNamespaceDeclarations}}
 | 
			
		||||
namespace {{this}} {
 | 
			
		||||
@ -10,15 +10,15 @@ namespace {{this}} {
 | 
			
		||||
 | 
			
		||||
class {{prefix}}Object {
 | 
			
		||||
  public:
 | 
			
		||||
    virtual QJsonObject* asJsonObject() {
 | 
			
		||||
      return new QJsonObject();
 | 
			
		||||
    virtual QJsonObject asJsonObject() {
 | 
			
		||||
      return QJsonObject();
 | 
			
		||||
    }
 | 
			
		||||
    virtual ~{{prefix}}Object() {}
 | 
			
		||||
    virtual {{prefix}}Object* fromJson(QString &jsonString) {
 | 
			
		||||
    virtual {{prefix}}Object* fromJson(QString jsonString) {
 | 
			
		||||
        Q_UNUSED(jsonString);
 | 
			
		||||
        return new {{prefix}}Object();
 | 
			
		||||
    }
 | 
			
		||||
    virtual void fromJsonObject(QJsonObject &json) {
 | 
			
		||||
    virtual void fromJsonObject(QJsonObject json) {
 | 
			
		||||
        Q_UNUSED(json);
 | 
			
		||||
    }
 | 
			
		||||
    virtual QString asJson() {
 | 
			
		||||
 | 
			
		||||
@ -22,9 +22,9 @@
 | 
			
		||||
 | 
			
		||||
namespace Swagger {
 | 
			
		||||
 | 
			
		||||
SWGApiResponse::SWGApiResponse(QString* json) {
 | 
			
		||||
SWGApiResponse::SWGApiResponse(QString json) {
 | 
			
		||||
    init();
 | 
			
		||||
    this->fromJson(*json);
 | 
			
		||||
    this->fromJson(json);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGApiResponse::SWGApiResponse() {
 | 
			
		||||
@ -57,7 +57,7 @@ SWGApiResponse::cleanup() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGApiResponse*
 | 
			
		||||
SWGApiResponse::fromJson(QString &json) {
 | 
			
		||||
SWGApiResponse::fromJson(QString json) {
 | 
			
		||||
    QByteArray array (json.toStdString().c_str());
 | 
			
		||||
    QJsonDocument doc = QJsonDocument::fromJson(array);
 | 
			
		||||
    QJsonObject jsonObject = doc.object();
 | 
			
		||||
@ -66,7 +66,7 @@ SWGApiResponse::fromJson(QString &json) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
SWGApiResponse::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
SWGApiResponse::fromJsonObject(QJsonObject pJson) {
 | 
			
		||||
    ::Swagger::setValue(&code, pJson["code"], "qint32", "");
 | 
			
		||||
    
 | 
			
		||||
    ::Swagger::setValue(&type, pJson["type"], "QString", "QString");
 | 
			
		||||
@ -78,18 +78,17 @@ SWGApiResponse::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
QString
 | 
			
		||||
SWGApiResponse::asJson ()
 | 
			
		||||
{
 | 
			
		||||
    QJsonObject* obj = this->asJsonObject();
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*obj);
 | 
			
		||||
    QJsonObject obj = this->asJsonObject();
 | 
			
		||||
    QJsonDocument doc(obj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
    return QString(bytes);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QJsonObject*
 | 
			
		||||
QJsonObject
 | 
			
		||||
SWGApiResponse::asJsonObject() {
 | 
			
		||||
    QJsonObject* obj = new QJsonObject();
 | 
			
		||||
    QJsonObject obj;
 | 
			
		||||
    if(m_code_isSet){
 | 
			
		||||
        obj->insert("code", QJsonValue(code));
 | 
			
		||||
        obj.insert("code", QJsonValue(code));
 | 
			
		||||
    }
 | 
			
		||||
    if(type != nullptr && *type != QString("")){
 | 
			
		||||
        toJsonValue(QString("type"), type, obj, QString("QString"));
 | 
			
		||||
 | 
			
		||||
@ -31,15 +31,15 @@ namespace Swagger {
 | 
			
		||||
class SWGApiResponse: public SWGObject {
 | 
			
		||||
public:
 | 
			
		||||
    SWGApiResponse();
 | 
			
		||||
    SWGApiResponse(QString* json);
 | 
			
		||||
    virtual ~SWGApiResponse();
 | 
			
		||||
    SWGApiResponse(QString json);
 | 
			
		||||
    ~SWGApiResponse();
 | 
			
		||||
    void init();
 | 
			
		||||
    void cleanup();
 | 
			
		||||
 | 
			
		||||
    QString asJson ();
 | 
			
		||||
    QJsonObject* asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject &json);
 | 
			
		||||
    SWGApiResponse* fromJson(QString &jsonString);
 | 
			
		||||
    QJsonObject asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject json);
 | 
			
		||||
    SWGApiResponse* fromJson(QString jsonString);
 | 
			
		||||
 | 
			
		||||
    qint32 getCode();
 | 
			
		||||
    void setCode(qint32 code);
 | 
			
		||||
 | 
			
		||||
@ -22,9 +22,9 @@
 | 
			
		||||
 | 
			
		||||
namespace Swagger {
 | 
			
		||||
 | 
			
		||||
SWGCategory::SWGCategory(QString* json) {
 | 
			
		||||
SWGCategory::SWGCategory(QString json) {
 | 
			
		||||
    init();
 | 
			
		||||
    this->fromJson(*json);
 | 
			
		||||
    this->fromJson(json);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGCategory::SWGCategory() {
 | 
			
		||||
@ -52,7 +52,7 @@ SWGCategory::cleanup() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGCategory*
 | 
			
		||||
SWGCategory::fromJson(QString &json) {
 | 
			
		||||
SWGCategory::fromJson(QString json) {
 | 
			
		||||
    QByteArray array (json.toStdString().c_str());
 | 
			
		||||
    QJsonDocument doc = QJsonDocument::fromJson(array);
 | 
			
		||||
    QJsonObject jsonObject = doc.object();
 | 
			
		||||
@ -61,7 +61,7 @@ SWGCategory::fromJson(QString &json) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
SWGCategory::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
SWGCategory::fromJsonObject(QJsonObject pJson) {
 | 
			
		||||
    ::Swagger::setValue(&id, pJson["id"], "qint64", "");
 | 
			
		||||
    
 | 
			
		||||
    ::Swagger::setValue(&name, pJson["name"], "QString", "QString");
 | 
			
		||||
@ -71,18 +71,17 @@ SWGCategory::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
QString
 | 
			
		||||
SWGCategory::asJson ()
 | 
			
		||||
{
 | 
			
		||||
    QJsonObject* obj = this->asJsonObject();
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*obj);
 | 
			
		||||
    QJsonObject obj = this->asJsonObject();
 | 
			
		||||
    QJsonDocument doc(obj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
    return QString(bytes);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QJsonObject*
 | 
			
		||||
QJsonObject
 | 
			
		||||
SWGCategory::asJsonObject() {
 | 
			
		||||
    QJsonObject* obj = new QJsonObject();
 | 
			
		||||
    QJsonObject obj;
 | 
			
		||||
    if(m_id_isSet){
 | 
			
		||||
        obj->insert("id", QJsonValue(id));
 | 
			
		||||
        obj.insert("id", QJsonValue(id));
 | 
			
		||||
    }
 | 
			
		||||
    if(name != nullptr && *name != QString("")){
 | 
			
		||||
        toJsonValue(QString("name"), name, obj, QString("QString"));
 | 
			
		||||
 | 
			
		||||
@ -31,15 +31,15 @@ namespace Swagger {
 | 
			
		||||
class SWGCategory: public SWGObject {
 | 
			
		||||
public:
 | 
			
		||||
    SWGCategory();
 | 
			
		||||
    SWGCategory(QString* json);
 | 
			
		||||
    virtual ~SWGCategory();
 | 
			
		||||
    SWGCategory(QString json);
 | 
			
		||||
    ~SWGCategory();
 | 
			
		||||
    void init();
 | 
			
		||||
    void cleanup();
 | 
			
		||||
 | 
			
		||||
    QString asJson ();
 | 
			
		||||
    QJsonObject* asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject &json);
 | 
			
		||||
    SWGCategory* fromJson(QString &jsonString);
 | 
			
		||||
    QJsonObject asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject json);
 | 
			
		||||
    SWGCategory* fromJson(QString jsonString);
 | 
			
		||||
 | 
			
		||||
    qint64 getId();
 | 
			
		||||
    void setId(qint64 id);
 | 
			
		||||
 | 
			
		||||
@ -41,7 +41,7 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("float").compare(type) == 0) {
 | 
			
		||||
        float *val = static_cast<float*>(value);
 | 
			
		||||
        *val = obj.toDouble();
 | 
			
		||||
        *val = static_cast<float>(obj.toDouble());
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("double").compare(type) == 0) {
 | 
			
		||||
        double *val = static_cast<double*>(value);
 | 
			
		||||
@ -51,20 +51,14 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
 | 
			
		||||
        QString **val = static_cast<QString**>(value);
 | 
			
		||||
        if(val != nullptr) {
 | 
			
		||||
            if(!obj.isNull()) {
 | 
			
		||||
                // create a new value and return
 | 
			
		||||
                if(*val != nullptr) delete *val;
 | 
			
		||||
                *val = new QString(obj.toString());
 | 
			
		||||
                (*val)->clear();
 | 
			
		||||
                (*val)->append(obj.toString());
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                // set target to nullptr
 | 
			
		||||
                if(*val != nullptr) delete *val;
 | 
			
		||||
                *val = nullptr;
 | 
			
		||||
                (*val)->clear();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            qDebug() << "Can't set value because the target pointer is nullptr";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if (QStringLiteral("QDateTime").compare(type) == 0) {
 | 
			
		||||
        QDateTime **val = static_cast<QDateTime**>(value);
 | 
			
		||||
@ -380,67 +374,66 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
 | 
			
		||||
toJsonValue(QString name, void* value, QJsonObject& output, QString type) {
 | 
			
		||||
    if(value == nullptr) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    if(type.startsWith("SWG")) {
 | 
			
		||||
        SWGObject *SWGobject = reinterpret_cast<SWGObject *>(value);
 | 
			
		||||
        if(SWGobject != nullptr) {
 | 
			
		||||
            QJsonObject* o = (*SWGobject).asJsonObject();
 | 
			
		||||
            if(name != nullptr) {
 | 
			
		||||
                output->insert(name, *o);
 | 
			
		||||
                if(o != nullptr) delete o;
 | 
			
		||||
            QJsonObject o = SWGobject->asJsonObject();
 | 
			
		||||
            if(!name.isNull()) {
 | 
			
		||||
                output.insert(name, o);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                output->empty();
 | 
			
		||||
                for(QString key : o->keys()) {
 | 
			
		||||
                    output->insert(key, o->value(key));
 | 
			
		||||
                output.empty();
 | 
			
		||||
                for(QString key : o.keys()) {
 | 
			
		||||
                    output.insert(key, o.value(key));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QString").compare(type) == 0) {
 | 
			
		||||
        QString* str = static_cast<QString*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint32").compare(type) == 0) {
 | 
			
		||||
        qint32* str = static_cast<qint32*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint64").compare(type) == 0) {
 | 
			
		||||
        qint64* str = static_cast<qint64*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("bool").compare(type) == 0) {
 | 
			
		||||
        bool* str = static_cast<bool*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("float").compare(type) == 0) {
 | 
			
		||||
        float* str = static_cast<float*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue((double)*str));
 | 
			
		||||
        output.insert(name, QJsonValue((double)*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("double").compare(type) == 0) {
 | 
			
		||||
        double* str = static_cast<double*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(*str));
 | 
			
		||||
        output.insert(name, QJsonValue(*str));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDate").compare(type) == 0) {
 | 
			
		||||
        QDate* date = static_cast<QDate*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(date->toString(Qt::ISODate)));
 | 
			
		||||
        output.insert(name, QJsonValue(date->toString(Qt::ISODate)));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDateTime").compare(type) == 0) {
 | 
			
		||||
        QDateTime* datetime = static_cast<QDateTime*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(datetime->toString(Qt::ISODate)));
 | 
			
		||||
        output.insert(name, QJsonValue(datetime->toString(Qt::ISODate)));
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QByteArray").compare(type) == 0) {
 | 
			
		||||
        QByteArray* byteArray = static_cast<QByteArray*>(value);
 | 
			
		||||
        output->insert(name, QJsonValue(QString(byteArray->toBase64())));
 | 
			
		||||
        output.insert(name, QJsonValue(QString(byteArray->toBase64())));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString innerType) {
 | 
			
		||||
    if((value == nullptr) || (output == nullptr)) {
 | 
			
		||||
toJsonArray(QList<void*>* value, QJsonObject& output, QString innerName, QString innerType) {
 | 
			
		||||
    if(value == nullptr) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    QJsonArray outputarray;
 | 
			
		||||
@ -448,7 +441,7 @@ toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString
 | 
			
		||||
        for(void* obj : *value) {
 | 
			
		||||
            SWGObject *SWGobject = reinterpret_cast<SWGObject *>(obj);
 | 
			
		||||
            if(SWGobject != nullptr) {
 | 
			
		||||
                outputarray.append(*(SWGobject->asJsonObject()));
 | 
			
		||||
                outputarray.append(SWGobject->asJsonObject());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -491,81 +484,81 @@ toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString
 | 
			
		||||
        for(double obj : *(reinterpret_cast<QList<double>*>(value)))
 | 
			
		||||
            outputarray.append(QJsonValue(obj));
 | 
			
		||||
    }
 | 
			
		||||
    output->insert(innerName, outputarray);
 | 
			
		||||
    output.insert(innerName, outputarray);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
toJsonMap(QMap<QString, void*>* value, QJsonObject* output, QString innerName, QString innerType) {
 | 
			
		||||
    if((value == nullptr) || (output == nullptr)) {
 | 
			
		||||
toJsonMap(QMap<QString, void*>* value, QJsonObject& output, QString innerName, QString innerType) {
 | 
			
		||||
    if(value == nullptr)  {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    QJsonObject mapobj;
 | 
			
		||||
    if(innerType.startsWith("SWG")){
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, SWGObject*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey),mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QString").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QString*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDate").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QDate*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QDateTime").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QDateTime*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("QByteArray").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, QByteArray*> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, items->value(itemkey), mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint32").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, qint32> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("qint64").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, qint64> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("bool").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, bool> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("float").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, float> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys()) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(QStringLiteral("double").compare(innerType) == 0) {
 | 
			
		||||
        auto items = reinterpret_cast< QMap<QString, double> *>(value);
 | 
			
		||||
        for(auto itemkey: items->keys() ) {
 | 
			
		||||
            auto val = items->value(itemkey);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, &mapobj, innerType);
 | 
			
		||||
            ::Swagger::toJsonValue(itemkey, &val, mapobj, innerType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    output->insert(innerName, mapobj);
 | 
			
		||||
    output.insert(innerName, mapobj);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString
 | 
			
		||||
 | 
			
		||||
@ -20,9 +20,9 @@
 | 
			
		||||
namespace Swagger {
 | 
			
		||||
 | 
			
		||||
    void setValue(void* value, QJsonValue obj, QString type, QString complexType);
 | 
			
		||||
    void toJsonArray(QList<void*>* value, QJsonObject* output, QString innerName, QString innerType);
 | 
			
		||||
    void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
 | 
			
		||||
    void toJsonMap(QMap<QString, void*>* value, QJsonObject* output, QString innerName, QString innerType);
 | 
			
		||||
    void toJsonArray(QList<void*>* value, QJsonObject& output, QString innerName, QString innerType);
 | 
			
		||||
    void toJsonValue(QString name, void* value, QJsonObject& output, QString type);
 | 
			
		||||
    void toJsonMap(QMap<QString, void*>* value, QJsonObject& output, QString innerName, QString innerType);
 | 
			
		||||
    bool isCompatibleJsonValue(QString type);
 | 
			
		||||
    QString stringValue(QString* value);
 | 
			
		||||
    QString stringValue(qint32 value);
 | 
			
		||||
 | 
			
		||||
@ -56,7 +56,7 @@ SWGHttpRequestWorker::SWGHttpRequestWorker(QObject *parent)
 | 
			
		||||
    qsrand(QDateTime::currentDateTime().toTime_t());
 | 
			
		||||
 | 
			
		||||
    manager = new QNetworkAccessManager(this);
 | 
			
		||||
    connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_manager_finished(QNetworkReply*)));
 | 
			
		||||
    connect(manager, &QNetworkAccessManager::finished, this, &SWGHttpRequestWorker::on_manager_finished);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGHttpRequestWorker::~SWGHttpRequestWorker() {
 | 
			
		||||
 | 
			
		||||
@ -47,13 +47,12 @@ namespace Swagger {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  inline void* create(QString json, QString type) {
 | 
			
		||||
    void* val = create(type);
 | 
			
		||||
    if(val != nullptr) {
 | 
			
		||||
      SWGObject* obj = static_cast<SWGObject*>(val);
 | 
			
		||||
      return obj->fromJson(json);
 | 
			
		||||
    }
 | 
			
		||||
    if(type.startsWith("QString")) {
 | 
			
		||||
      return new QString();
 | 
			
		||||
    }    
 | 
			
		||||
    auto val = static_cast<SWGObject*>(create(type));
 | 
			
		||||
    if(val != nullptr) {
 | 
			
		||||
      return val->fromJson(json);
 | 
			
		||||
    }
 | 
			
		||||
    return nullptr;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -19,15 +19,15 @@ namespace Swagger {
 | 
			
		||||
 | 
			
		||||
class SWGObject {
 | 
			
		||||
  public:
 | 
			
		||||
    virtual QJsonObject* asJsonObject() {
 | 
			
		||||
      return new QJsonObject();
 | 
			
		||||
    virtual QJsonObject asJsonObject() {
 | 
			
		||||
      return QJsonObject();
 | 
			
		||||
    }
 | 
			
		||||
    virtual ~SWGObject() {}
 | 
			
		||||
    virtual SWGObject* fromJson(QString &jsonString) {
 | 
			
		||||
    virtual SWGObject* fromJson(QString jsonString) {
 | 
			
		||||
        Q_UNUSED(jsonString);
 | 
			
		||||
        return new SWGObject();
 | 
			
		||||
    }
 | 
			
		||||
    virtual void fromJsonObject(QJsonObject &json) {
 | 
			
		||||
    virtual void fromJsonObject(QJsonObject json) {
 | 
			
		||||
        Q_UNUSED(json);
 | 
			
		||||
    }
 | 
			
		||||
    virtual QString asJson() {
 | 
			
		||||
 | 
			
		||||
@ -22,9 +22,9 @@
 | 
			
		||||
 | 
			
		||||
namespace Swagger {
 | 
			
		||||
 | 
			
		||||
SWGOrder::SWGOrder(QString* json) {
 | 
			
		||||
SWGOrder::SWGOrder(QString json) {
 | 
			
		||||
    init();
 | 
			
		||||
    this->fromJson(*json);
 | 
			
		||||
    this->fromJson(json);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGOrder::SWGOrder() {
 | 
			
		||||
@ -66,7 +66,7 @@ SWGOrder::cleanup() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGOrder*
 | 
			
		||||
SWGOrder::fromJson(QString &json) {
 | 
			
		||||
SWGOrder::fromJson(QString json) {
 | 
			
		||||
    QByteArray array (json.toStdString().c_str());
 | 
			
		||||
    QJsonDocument doc = QJsonDocument::fromJson(array);
 | 
			
		||||
    QJsonObject jsonObject = doc.object();
 | 
			
		||||
@ -75,7 +75,7 @@ SWGOrder::fromJson(QString &json) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
SWGOrder::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
SWGOrder::fromJsonObject(QJsonObject pJson) {
 | 
			
		||||
    ::Swagger::setValue(&id, pJson["id"], "qint64", "");
 | 
			
		||||
    
 | 
			
		||||
    ::Swagger::setValue(&pet_id, pJson["petId"], "qint64", "");
 | 
			
		||||
@ -93,24 +93,23 @@ SWGOrder::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
QString
 | 
			
		||||
SWGOrder::asJson ()
 | 
			
		||||
{
 | 
			
		||||
    QJsonObject* obj = this->asJsonObject();
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*obj);
 | 
			
		||||
    QJsonObject obj = this->asJsonObject();
 | 
			
		||||
    QJsonDocument doc(obj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
    return QString(bytes);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QJsonObject*
 | 
			
		||||
QJsonObject
 | 
			
		||||
SWGOrder::asJsonObject() {
 | 
			
		||||
    QJsonObject* obj = new QJsonObject();
 | 
			
		||||
    QJsonObject obj;
 | 
			
		||||
    if(m_id_isSet){
 | 
			
		||||
        obj->insert("id", QJsonValue(id));
 | 
			
		||||
        obj.insert("id", QJsonValue(id));
 | 
			
		||||
    }
 | 
			
		||||
    if(m_pet_id_isSet){
 | 
			
		||||
        obj->insert("petId", QJsonValue(pet_id));
 | 
			
		||||
        obj.insert("petId", QJsonValue(pet_id));
 | 
			
		||||
    }
 | 
			
		||||
    if(m_quantity_isSet){
 | 
			
		||||
        obj->insert("quantity", QJsonValue(quantity));
 | 
			
		||||
        obj.insert("quantity", QJsonValue(quantity));
 | 
			
		||||
    }
 | 
			
		||||
    if(ship_date != nullptr) { 
 | 
			
		||||
        toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
 | 
			
		||||
@ -119,7 +118,7 @@ SWGOrder::asJsonObject() {
 | 
			
		||||
        toJsonValue(QString("status"), status, obj, QString("QString"));
 | 
			
		||||
    }
 | 
			
		||||
    if(m_complete_isSet){
 | 
			
		||||
        obj->insert("complete", QJsonValue(complete));
 | 
			
		||||
        obj.insert("complete", QJsonValue(complete));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return obj;
 | 
			
		||||
 | 
			
		||||
@ -32,15 +32,15 @@ namespace Swagger {
 | 
			
		||||
class SWGOrder: public SWGObject {
 | 
			
		||||
public:
 | 
			
		||||
    SWGOrder();
 | 
			
		||||
    SWGOrder(QString* json);
 | 
			
		||||
    virtual ~SWGOrder();
 | 
			
		||||
    SWGOrder(QString json);
 | 
			
		||||
    ~SWGOrder();
 | 
			
		||||
    void init();
 | 
			
		||||
    void cleanup();
 | 
			
		||||
 | 
			
		||||
    QString asJson ();
 | 
			
		||||
    QJsonObject* asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject &json);
 | 
			
		||||
    SWGOrder* fromJson(QString &jsonString);
 | 
			
		||||
    QJsonObject asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject json);
 | 
			
		||||
    SWGOrder* fromJson(QString jsonString);
 | 
			
		||||
 | 
			
		||||
    qint64 getId();
 | 
			
		||||
    void setId(qint64 id);
 | 
			
		||||
 | 
			
		||||
@ -22,9 +22,9 @@
 | 
			
		||||
 | 
			
		||||
namespace Swagger {
 | 
			
		||||
 | 
			
		||||
SWGPet::SWGPet(QString* json) {
 | 
			
		||||
SWGPet::SWGPet(QString json) {
 | 
			
		||||
    init();
 | 
			
		||||
    this->fromJson(*json);
 | 
			
		||||
    this->fromJson(json);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGPet::SWGPet() {
 | 
			
		||||
@ -80,7 +80,7 @@ SWGPet::cleanup() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGPet*
 | 
			
		||||
SWGPet::fromJson(QString &json) {
 | 
			
		||||
SWGPet::fromJson(QString json) {
 | 
			
		||||
    QByteArray array (json.toStdString().c_str());
 | 
			
		||||
    QJsonDocument doc = QJsonDocument::fromJson(array);
 | 
			
		||||
    QJsonObject jsonObject = doc.object();
 | 
			
		||||
@ -89,7 +89,7 @@ SWGPet::fromJson(QString &json) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
SWGPet::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
SWGPet::fromJsonObject(QJsonObject pJson) {
 | 
			
		||||
    ::Swagger::setValue(&id, pJson["id"], "qint64", "");
 | 
			
		||||
    
 | 
			
		||||
    ::Swagger::setValue(&category, pJson["category"], "SWGCategory", "SWGCategory");
 | 
			
		||||
@ -107,18 +107,17 @@ SWGPet::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
QString
 | 
			
		||||
SWGPet::asJson ()
 | 
			
		||||
{
 | 
			
		||||
    QJsonObject* obj = this->asJsonObject();
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*obj);
 | 
			
		||||
    QJsonObject obj = this->asJsonObject();
 | 
			
		||||
    QJsonDocument doc(obj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
    return QString(bytes);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QJsonObject*
 | 
			
		||||
QJsonObject
 | 
			
		||||
SWGPet::asJsonObject() {
 | 
			
		||||
    QJsonObject* obj = new QJsonObject();
 | 
			
		||||
    QJsonObject obj;
 | 
			
		||||
    if(m_id_isSet){
 | 
			
		||||
        obj->insert("id", QJsonValue(id));
 | 
			
		||||
        obj.insert("id", QJsonValue(id));
 | 
			
		||||
    }
 | 
			
		||||
    if((category != nullptr) && (category->isSet())){
 | 
			
		||||
        toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
 | 
			
		||||
 | 
			
		||||
@ -34,15 +34,15 @@ namespace Swagger {
 | 
			
		||||
class SWGPet: public SWGObject {
 | 
			
		||||
public:
 | 
			
		||||
    SWGPet();
 | 
			
		||||
    SWGPet(QString* json);
 | 
			
		||||
    virtual ~SWGPet();
 | 
			
		||||
    SWGPet(QString json);
 | 
			
		||||
    ~SWGPet();
 | 
			
		||||
    void init();
 | 
			
		||||
    void cleanup();
 | 
			
		||||
 | 
			
		||||
    QString asJson ();
 | 
			
		||||
    QJsonObject* asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject &json);
 | 
			
		||||
    SWGPet* fromJson(QString &jsonString);
 | 
			
		||||
    QJsonObject asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject json);
 | 
			
		||||
    SWGPet* fromJson(QString jsonString);
 | 
			
		||||
 | 
			
		||||
    qint64 getId();
 | 
			
		||||
    void setId(qint64 id);
 | 
			
		||||
 | 
			
		||||
@ -127,7 +127,7 @@ SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) {
 | 
			
		||||
 | 
			
		||||
    foreach(QString key, obj.keys()) {
 | 
			
		||||
        qint32* val;
 | 
			
		||||
        setValue(&val, obj[key], "qint32", "");
 | 
			
		||||
        setValue(&val, obj[key], "qint32", QString());
 | 
			
		||||
        output->insert(key, *val);
 | 
			
		||||
    }
 | 
			
		||||
    worker->deleteLater();
 | 
			
		||||
 | 
			
		||||
@ -22,9 +22,9 @@
 | 
			
		||||
 | 
			
		||||
namespace Swagger {
 | 
			
		||||
 | 
			
		||||
SWGTag::SWGTag(QString* json) {
 | 
			
		||||
SWGTag::SWGTag(QString json) {
 | 
			
		||||
    init();
 | 
			
		||||
    this->fromJson(*json);
 | 
			
		||||
    this->fromJson(json);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGTag::SWGTag() {
 | 
			
		||||
@ -52,7 +52,7 @@ SWGTag::cleanup() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGTag*
 | 
			
		||||
SWGTag::fromJson(QString &json) {
 | 
			
		||||
SWGTag::fromJson(QString json) {
 | 
			
		||||
    QByteArray array (json.toStdString().c_str());
 | 
			
		||||
    QJsonDocument doc = QJsonDocument::fromJson(array);
 | 
			
		||||
    QJsonObject jsonObject = doc.object();
 | 
			
		||||
@ -61,7 +61,7 @@ SWGTag::fromJson(QString &json) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
SWGTag::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
SWGTag::fromJsonObject(QJsonObject pJson) {
 | 
			
		||||
    ::Swagger::setValue(&id, pJson["id"], "qint64", "");
 | 
			
		||||
    
 | 
			
		||||
    ::Swagger::setValue(&name, pJson["name"], "QString", "QString");
 | 
			
		||||
@ -71,18 +71,17 @@ SWGTag::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
QString
 | 
			
		||||
SWGTag::asJson ()
 | 
			
		||||
{
 | 
			
		||||
    QJsonObject* obj = this->asJsonObject();
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*obj);
 | 
			
		||||
    QJsonObject obj = this->asJsonObject();
 | 
			
		||||
    QJsonDocument doc(obj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
    return QString(bytes);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QJsonObject*
 | 
			
		||||
QJsonObject
 | 
			
		||||
SWGTag::asJsonObject() {
 | 
			
		||||
    QJsonObject* obj = new QJsonObject();
 | 
			
		||||
    QJsonObject obj;
 | 
			
		||||
    if(m_id_isSet){
 | 
			
		||||
        obj->insert("id", QJsonValue(id));
 | 
			
		||||
        obj.insert("id", QJsonValue(id));
 | 
			
		||||
    }
 | 
			
		||||
    if(name != nullptr && *name != QString("")){
 | 
			
		||||
        toJsonValue(QString("name"), name, obj, QString("QString"));
 | 
			
		||||
 | 
			
		||||
@ -31,15 +31,15 @@ namespace Swagger {
 | 
			
		||||
class SWGTag: public SWGObject {
 | 
			
		||||
public:
 | 
			
		||||
    SWGTag();
 | 
			
		||||
    SWGTag(QString* json);
 | 
			
		||||
    virtual ~SWGTag();
 | 
			
		||||
    SWGTag(QString json);
 | 
			
		||||
    ~SWGTag();
 | 
			
		||||
    void init();
 | 
			
		||||
    void cleanup();
 | 
			
		||||
 | 
			
		||||
    QString asJson ();
 | 
			
		||||
    QJsonObject* asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject &json);
 | 
			
		||||
    SWGTag* fromJson(QString &jsonString);
 | 
			
		||||
    QJsonObject asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject json);
 | 
			
		||||
    SWGTag* fromJson(QString jsonString);
 | 
			
		||||
 | 
			
		||||
    qint64 getId();
 | 
			
		||||
    void setId(qint64 id);
 | 
			
		||||
 | 
			
		||||
@ -22,9 +22,9 @@
 | 
			
		||||
 | 
			
		||||
namespace Swagger {
 | 
			
		||||
 | 
			
		||||
SWGUser::SWGUser(QString* json) {
 | 
			
		||||
SWGUser::SWGUser(QString json) {
 | 
			
		||||
    init();
 | 
			
		||||
    this->fromJson(*json);
 | 
			
		||||
    this->fromJson(json);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGUser::SWGUser() {
 | 
			
		||||
@ -80,7 +80,7 @@ SWGUser::cleanup() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SWGUser*
 | 
			
		||||
SWGUser::fromJson(QString &json) {
 | 
			
		||||
SWGUser::fromJson(QString json) {
 | 
			
		||||
    QByteArray array (json.toStdString().c_str());
 | 
			
		||||
    QJsonDocument doc = QJsonDocument::fromJson(array);
 | 
			
		||||
    QJsonObject jsonObject = doc.object();
 | 
			
		||||
@ -89,7 +89,7 @@ SWGUser::fromJson(QString &json) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
SWGUser::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
SWGUser::fromJsonObject(QJsonObject pJson) {
 | 
			
		||||
    ::Swagger::setValue(&id, pJson["id"], "qint64", "");
 | 
			
		||||
    
 | 
			
		||||
    ::Swagger::setValue(&username, pJson["username"], "QString", "QString");
 | 
			
		||||
@ -111,18 +111,17 @@ SWGUser::fromJsonObject(QJsonObject &pJson) {
 | 
			
		||||
QString
 | 
			
		||||
SWGUser::asJson ()
 | 
			
		||||
{
 | 
			
		||||
    QJsonObject* obj = this->asJsonObject();
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*obj);
 | 
			
		||||
    QJsonObject obj = this->asJsonObject();
 | 
			
		||||
    QJsonDocument doc(obj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
    return QString(bytes);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QJsonObject*
 | 
			
		||||
QJsonObject
 | 
			
		||||
SWGUser::asJsonObject() {
 | 
			
		||||
    QJsonObject* obj = new QJsonObject();
 | 
			
		||||
    QJsonObject obj;
 | 
			
		||||
    if(m_id_isSet){
 | 
			
		||||
        obj->insert("id", QJsonValue(id));
 | 
			
		||||
        obj.insert("id", QJsonValue(id));
 | 
			
		||||
    }
 | 
			
		||||
    if(username != nullptr && *username != QString("")){
 | 
			
		||||
        toJsonValue(QString("username"), username, obj, QString("QString"));
 | 
			
		||||
@ -143,7 +142,7 @@ SWGUser::asJsonObject() {
 | 
			
		||||
        toJsonValue(QString("phone"), phone, obj, QString("QString"));
 | 
			
		||||
    }
 | 
			
		||||
    if(m_user_status_isSet){
 | 
			
		||||
        obj->insert("userStatus", QJsonValue(user_status));
 | 
			
		||||
        obj.insert("userStatus", QJsonValue(user_status));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return obj;
 | 
			
		||||
 | 
			
		||||
@ -31,15 +31,15 @@ namespace Swagger {
 | 
			
		||||
class SWGUser: public SWGObject {
 | 
			
		||||
public:
 | 
			
		||||
    SWGUser();
 | 
			
		||||
    SWGUser(QString* json);
 | 
			
		||||
    virtual ~SWGUser();
 | 
			
		||||
    SWGUser(QString json);
 | 
			
		||||
    ~SWGUser();
 | 
			
		||||
    void init();
 | 
			
		||||
    void cleanup();
 | 
			
		||||
 | 
			
		||||
    QString asJson ();
 | 
			
		||||
    QJsonObject* asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject &json);
 | 
			
		||||
    SWGUser* fromJson(QString &jsonString);
 | 
			
		||||
    QJsonObject asJsonObject();
 | 
			
		||||
    void fromJsonObject(QJsonObject json);
 | 
			
		||||
    SWGUser* fromJson(QString jsonString);
 | 
			
		||||
 | 
			
		||||
    qint64 getId();
 | 
			
		||||
    void setId(qint64 id);
 | 
			
		||||
 | 
			
		||||
@ -91,10 +91,10 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>*& body) {
 | 
			
		||||
    SWGHttpRequestInput input(fullPath, "POST");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    auto body_jobj = new QJsonObject();
 | 
			
		||||
    QJsonObject body_jobj;
 | 
			
		||||
    toJsonArray((QList<void*>*)body, body_jobj, QString("body"), QString("SWGUser*"));
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*body_jobj);
 | 
			
		||||
    QJsonDocument doc(body_jobj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
 | 
			
		||||
    input.request_body.append(bytes);
 | 
			
		||||
@ -147,10 +147,10 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>*& body) {
 | 
			
		||||
    SWGHttpRequestInput input(fullPath, "POST");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    auto body_jobj = new QJsonObject();
 | 
			
		||||
    QJsonObject body_jobj;
 | 
			
		||||
    toJsonArray((QList<void*>*)body, body_jobj, QString("body"), QString("SWGUser*"));
 | 
			
		||||
 | 
			
		||||
    QJsonDocument doc(*body_jobj);
 | 
			
		||||
    QJsonDocument doc(body_jobj);
 | 
			
		||||
    QByteArray bytes = doc.toJson();
 | 
			
		||||
 | 
			
		||||
    input.request_body.append(bytes);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user