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