forked from loafle/openapi-generator-original
roll back qt5cpp template
This commit is contained in:
parent
263b4080ee
commit
6253bbff3d
@ -2,10 +2,8 @@
|
||||
#include "{{prefix}}Helpers.h"
|
||||
#include "{{prefix}}ModelFactory.h"
|
||||
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace Swagger {
|
||||
{{classname}}::{{classname}}() {}
|
||||
@ -20,8 +18,7 @@
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
void
|
||||
{{classname}}::{{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}
|
||||
, {{/hasMore}}{{/allParams}}) {
|
||||
{{classname}}::{{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("{{path}}");
|
||||
|
||||
@ -98,9 +95,7 @@
|
||||
{{#bodyParams}}
|
||||
{{#isContainer}}
|
||||
QJsonArray* {{paramName}}Array = new QJsonArray();
|
||||
toJsonArray((QList
|
||||
<void
|
||||
*>*){{paramName}}, {{paramName}}Array, QString("body"), QString("SWGUser*"));
|
||||
toJsonArray((QList<void*>*){{paramName}}, {{paramName}}Array, QString("body"), QString("SWGUser*"));
|
||||
|
||||
QJsonDocument doc(*{{paramName}}Array);
|
||||
QByteArray bytes = doc.toJson();
|
||||
@ -171,8 +166,7 @@
|
||||
{{/isMapContainer}}
|
||||
{{^isMapContainer}}
|
||||
{{^returnTypeIsPrimitive}}QString json(worker->response);
|
||||
{{{returnType}}} output = static_cast<{{{returnType}}}>(create(json,
|
||||
QString("{{{returnBaseType}}}")));
|
||||
{{{returnType}}} output = static_cast<{{{returnType}}}>(create(json, QString("{{{returnBaseType}}}")));
|
||||
{{/returnTypeIsPrimitive}}
|
||||
{{/isMapContainer}}
|
||||
{{/isListContainer}}{{/returnType}}
|
||||
|
@ -6,8 +6,7 @@
|
||||
{{#imports}}{{{import}}}
|
||||
{{/imports}}
|
||||
|
||||
#include
|
||||
<QObject>
|
||||
#include <QObject>
|
||||
|
||||
namespace Swagger {
|
||||
|
||||
@ -22,8 +21,7 @@
|
||||
QString host;
|
||||
QString basePath;
|
||||
|
||||
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}
|
||||
, {{/hasMore}}{{/allParams}});
|
||||
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/operation}}{{/operations}}
|
||||
private:
|
||||
{{#operations}}{{#operation}}void {{nickname}}Callback (HttpRequestWorker * worker);
|
||||
|
@ -1,12 +1,9 @@
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGModelFactory.h"
|
||||
#include "SWGObject.h"
|
||||
#import
|
||||
<QDebug>
|
||||
#import
|
||||
<QJsonArray>
|
||||
#import
|
||||
<QJsonValue>
|
||||
#import <QDebug>
|
||||
#import <QJsonArray>
|
||||
#import <QJsonValue>
|
||||
|
||||
namespace Swagger {
|
||||
|
||||
@ -17,27 +14,19 @@
|
||||
return;
|
||||
}
|
||||
if(QStringLiteral("bool").compare(type) == 0) {
|
||||
bool * val = static_cast
|
||||
<bool
|
||||
*>(value);
|
||||
bool * val = static_cast<bool*>(value);
|
||||
*val = obj.toBool();
|
||||
}
|
||||
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||
qint32 *val = static_cast
|
||||
<qint32
|
||||
*>(value);
|
||||
qint32 *val = static_cast<qint32*>(value);
|
||||
*val = obj.toInt();
|
||||
}
|
||||
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||
qint64 *val = static_cast
|
||||
<qint64
|
||||
*>(value);
|
||||
qint64 *val = static_cast<qint64*>(value);
|
||||
*val = obj.toVariant().toLongLong();
|
||||
}
|
||||
else if (QStringLiteral("QString").compare(type) == 0) {
|
||||
QString **val = static_cast
|
||||
<QString
|
||||
**>(value);
|
||||
QString **val = static_cast<QString**>(value);
|
||||
|
||||
if(val != NULL) {
|
||||
if(!obj.isNull()) {
|
||||
@ -62,20 +51,14 @@
|
||||
SWGObject * so = (SWGObject*)Swagger::create(type);
|
||||
if(so != NULL) {
|
||||
so->fromJsonObject(jsonObj);
|
||||
SWGObject **val = static_cast
|
||||
<SWGObject
|
||||
**>(value);
|
||||
SWGObject **val = static_cast<SWGObject**>(value);
|
||||
delete *val;
|
||||
*val = so;
|
||||
}
|
||||
}
|
||||
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
|
||||
// list of values
|
||||
QList
|
||||
<void
|
||||
*>* output = new QList
|
||||
<void
|
||||
*>();
|
||||
QList<void*>* output = new QList<void*>();
|
||||
QJsonArray arr = obj.toArray();
|
||||
foreach (const QJsonValue & jval, arr) {
|
||||
if(complexType.startsWith("SWG")) {
|
||||
@ -105,12 +88,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
QList
|
||||
<void
|
||||
*> **val = static_cast
|
||||
<QList
|
||||
<void
|
||||
*>**>(value);
|
||||
QList<void*> **val = static_cast<QList<void*>**>(value);
|
||||
delete *val;
|
||||
*val = output;
|
||||
}
|
||||
@ -122,8 +100,7 @@
|
||||
return;
|
||||
}
|
||||
if(type.startsWith("SWG")) {
|
||||
SWGObject *swgObject = reinterpret_cast
|
||||
<SWGObject *>(value);
|
||||
SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
|
||||
if(swgObject != NULL) {
|
||||
QJsonObject* o = (*swgObject).asJsonObject();
|
||||
if(name != NULL) {
|
||||
@ -139,35 +116,25 @@
|
||||
}
|
||||
}
|
||||
else if(QStringLiteral("QString").compare(type) == 0) {
|
||||
QString* str = static_cast
|
||||
<QString
|
||||
*>(value);
|
||||
QString* str = static_cast<QString*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||
qint32* str = static_cast
|
||||
<qint32
|
||||
*>(value);
|
||||
qint32* str = static_cast<qint32*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||
qint64* str = static_cast
|
||||
<qint64
|
||||
*>(value);
|
||||
qint64* str = static_cast<qint64*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
else if(QStringLiteral("bool").compare(type) == 0) {
|
||||
bool* str = static_cast
|
||||
<bool
|
||||
*>(value);
|
||||
bool* str = static_cast<bool*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
toJsonArray(QList
|
||||
<void
|
||||
*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||
foreach(void* obj, *value) {
|
||||
QJsonObject element;
|
||||
|
||||
@ -178,9 +145,7 @@
|
||||
|
||||
QString
|
||||
stringValue(QString* value) {
|
||||
QString* str = static_cast
|
||||
<QString
|
||||
*>(value);
|
||||
QString* str = static_cast<QString*>(value);
|
||||
return QString(*str);
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,11 @@
|
||||
#ifndef SWGHELPERS_H
|
||||
#define SWGHELPERS_H
|
||||
|
||||
#include
|
||||
<QJsonValue>
|
||||
#include <QJsonValue>
|
||||
|
||||
namespace Swagger {
|
||||
void setValue(void* value, QJsonValue obj, QString type, QString complexType);
|
||||
void toJsonArray(QList
|
||||
<void
|
||||
*>* value, QJsonArray* output, QString innerName, QString innerType);
|
||||
void toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType);
|
||||
void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
|
||||
bool isCompatibleJsonValue(QString type);
|
||||
QString stringValue(QString* value);
|
||||
|
@ -3,14 +3,10 @@
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QObject>
|
||||
#include
|
||||
<QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Swagger {
|
||||
|
||||
@ -84,8 +80,7 @@
|
||||
{{/isContainer}}{{#isContainer}}
|
||||
QList<{{complexType}}*>* {{name}}List = {{name}};
|
||||
QJsonArray {{name}}JsonArray;
|
||||
toJsonArray((QList
|
||||
<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
|
||||
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
|
||||
|
||||
obj->insert("{{name}}", {{name}}JsonArray);
|
||||
{{/isContainer}}
|
||||
|
@ -7,8 +7,7 @@
|
||||
#ifndef {{classname}}_H_
|
||||
#define {{classname}}_H_
|
||||
|
||||
#include
|
||||
<QJsonObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
{{/model}}{{/models}}
|
||||
{{#imports}}{{{import}}}
|
||||
|
@ -7,14 +7,10 @@
|
||||
#ifndef {{classname}}_H_
|
||||
#define {{classname}}_H_
|
||||
|
||||
#include
|
||||
<FApp.h>
|
||||
#include
|
||||
<FBase.h>
|
||||
#include
|
||||
<FSystem.h>
|
||||
#include
|
||||
<FWebJson.h>
|
||||
#include <FApp.h>
|
||||
#include <FBase.h>
|
||||
#include <FSystem.h>
|
||||
#include <FWebJson.h>
|
||||
#include "{{prefix}}Helpers.h"
|
||||
#include "{{prefix}}Object.h"
|
||||
|
||||
|
@ -16,8 +16,7 @@ return NULL;
|
||||
inline void* create(QString json, QString type) {
|
||||
void* val = create(type);
|
||||
if(val != NULL) {
|
||||
SWGObject* obj = static_cast
|
||||
<SWGObject*>(val);
|
||||
SWGObject* obj = static_cast<SWGObject*>(val);
|
||||
return obj->fromJson(json);
|
||||
}
|
||||
if(type.startsWith("QString")) {
|
||||
|
@ -1,8 +1,7 @@
|
||||
#ifndef _{{prefix}}_OBJECT_H_
|
||||
#define _{{prefix}}_OBJECT_H_
|
||||
|
||||
#include
|
||||
<QJsonValue>
|
||||
#include <QJsonValue>
|
||||
|
||||
class {{prefix}}Object {
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user