forked from loafle/openapi-generator-original
roll back qt5cpp template
This commit is contained in:
parent
263b4080ee
commit
6253bbff3d
@ -2,186 +2,180 @@
|
|||||||
#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}}() {}
|
||||||
|
|
||||||
{{classname}}::~{{classname}}() {}
|
{{classname}}::~{{classname}}() {}
|
||||||
|
|
||||||
{{classname}}::{{classname}}(QString host, QString basePath) {
|
{{classname}}::{{classname}}(QString host, QString basePath) {
|
||||||
this->host = host;
|
this->host = host;
|
||||||
this->basePath = basePath;
|
this->basePath = basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
void
|
||||||
|
{{classname}}::{{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||||
|
QString fullPath;
|
||||||
|
fullPath.append(this->host).append(this->basePath).append("{{path}}");
|
||||||
|
|
||||||
|
{{#pathParams}}
|
||||||
|
QString {{paramName}}PathParam("{"); {{paramName}}PathParam.append("{{paramName}}").append("}");
|
||||||
|
fullPath.replace({{paramName}}PathParam, stringValue({{paramName}}));
|
||||||
|
{{/pathParams}}
|
||||||
|
|
||||||
|
{{#queryParams}}
|
||||||
|
{{^collectionFormat}}
|
||||||
|
if(fullPath.indexOf("?") > 0)
|
||||||
|
fullPath.append("&");
|
||||||
|
else
|
||||||
|
fullPath.append("?");
|
||||||
|
fullPath.append(QUrl::toPercentEncoding("{{paramName}}"))
|
||||||
|
.append("=")
|
||||||
|
.append(QUrl::toPercentEncoding(stringValue({{paramName}})));
|
||||||
|
{{/collectionFormat}}
|
||||||
|
|
||||||
|
{{#collectionFormat}}
|
||||||
|
|
||||||
|
if({{{paramName}}}->size() > 0) {
|
||||||
|
if(QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
||||||
|
foreach({{{baseType}}} t, *{{paramName}}) {
|
||||||
|
if(fullPath.indexOf("?") > 0)
|
||||||
|
fullPath.append("&");
|
||||||
|
else
|
||||||
|
fullPath.append("?");
|
||||||
|
fullPath.append("{{{paramName}}}=").append(stringValue(t));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (QString("{{collectionFormat}}").indexOf("ssv") == 0) {
|
||||||
|
if(fullPath.indexOf("?") > 0)
|
||||||
|
fullPath.append("&");
|
||||||
|
else
|
||||||
|
fullPath.append("?");
|
||||||
|
fullPath.append("{{paramName}}=");
|
||||||
|
qint32 count = 0;
|
||||||
|
foreach({{{baseType}}} t, *{{paramName}}) {
|
||||||
|
if(count > 0) {
|
||||||
|
fullPath.append(" ");
|
||||||
|
}
|
||||||
|
fullPath.append(stringValue(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) {
|
||||||
|
if(fullPath.indexOf("?") > 0)
|
||||||
|
fullPath.append("&");
|
||||||
|
else
|
||||||
|
fullPath.append("?");
|
||||||
|
fullPath.append("{{paramName}}=");
|
||||||
|
qint32 count = 0;
|
||||||
|
foreach({{{baseType}}} t, *{{paramName}}) {
|
||||||
|
if(count > 0) {
|
||||||
|
fullPath.append("\t");
|
||||||
|
}
|
||||||
|
fullPath.append(stringValue(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{{#operations}}
|
{{/collectionFormat}}
|
||||||
{{#operation}}
|
{{/queryParams}}
|
||||||
void
|
|
||||||
{{classname}}::{{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}
|
|
||||||
, {{/hasMore}}{{/allParams}}) {
|
|
||||||
QString fullPath;
|
|
||||||
fullPath.append(this->host).append(this->basePath).append("{{path}}");
|
|
||||||
|
|
||||||
{{#pathParams}}
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
QString {{paramName}}PathParam("{"); {{paramName}}PathParam.append("{{paramName}}").append("}");
|
HttpRequestInput input(fullPath, "{{httpMethod}}");
|
||||||
fullPath.replace({{paramName}}PathParam, stringValue({{paramName}}));
|
|
||||||
{{/pathParams}}
|
|
||||||
|
|
||||||
{{#queryParams}}
|
{{#formParams}}{{^isFile}}
|
||||||
{{^collectionFormat}}
|
if({{paramName}} != NULL) {
|
||||||
if(fullPath.indexOf("?") > 0)
|
input.add_var("{{paramName}}", *{{paramName}});
|
||||||
fullPath.append("&");
|
}
|
||||||
else
|
{{/isFile}}{{/formParams}}
|
||||||
fullPath.append("?");
|
|
||||||
fullPath.append(QUrl::toPercentEncoding("{{paramName}}"))
|
|
||||||
.append("=")
|
|
||||||
.append(QUrl::toPercentEncoding(stringValue({{paramName}})));
|
|
||||||
{{/collectionFormat}}
|
|
||||||
|
|
||||||
{{#collectionFormat}}
|
{{#bodyParams}}
|
||||||
|
{{#isContainer}}
|
||||||
|
QJsonArray* {{paramName}}Array = new QJsonArray();
|
||||||
|
toJsonArray((QList<void*>*){{paramName}}, {{paramName}}Array, QString("body"), QString("SWGUser*"));
|
||||||
|
|
||||||
if({{{paramName}}}->size() > 0) {
|
QJsonDocument doc(*{{paramName}}Array);
|
||||||
if(QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
QByteArray bytes = doc.toJson();
|
||||||
foreach({{{baseType}}} t, *{{paramName}}) {
|
|
||||||
if(fullPath.indexOf("?") > 0)
|
|
||||||
fullPath.append("&");
|
|
||||||
else
|
|
||||||
fullPath.append("?");
|
|
||||||
fullPath.append("{{{paramName}}}=").append(stringValue(t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (QString("{{collectionFormat}}").indexOf("ssv") == 0) {
|
|
||||||
if(fullPath.indexOf("?") > 0)
|
|
||||||
fullPath.append("&");
|
|
||||||
else
|
|
||||||
fullPath.append("?");
|
|
||||||
fullPath.append("{{paramName}}=");
|
|
||||||
qint32 count = 0;
|
|
||||||
foreach({{{baseType}}} t, *{{paramName}}) {
|
|
||||||
if(count > 0) {
|
|
||||||
fullPath.append(" ");
|
|
||||||
}
|
|
||||||
fullPath.append(stringValue(t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) {
|
|
||||||
if(fullPath.indexOf("?") > 0)
|
|
||||||
fullPath.append("&");
|
|
||||||
else
|
|
||||||
fullPath.append("?");
|
|
||||||
fullPath.append("{{paramName}}=");
|
|
||||||
qint32 count = 0;
|
|
||||||
foreach({{{baseType}}} t, *{{paramName}}) {
|
|
||||||
if(count > 0) {
|
|
||||||
fullPath.append("\t");
|
|
||||||
}
|
|
||||||
fullPath.append(stringValue(t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/collectionFormat}}
|
input.request_body.append(bytes);
|
||||||
{{/queryParams}}
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
QString output = {{paramName}}.asJson();
|
||||||
|
input.request_body.append(output);
|
||||||
|
{{/isContainer}}{{/bodyParams}}
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
{{#headerParams}}
|
||||||
HttpRequestInput input(fullPath, "{{httpMethod}}");
|
// TODO: add header support
|
||||||
|
{{/headerParams}}
|
||||||
|
|
||||||
{{#formParams}}{{^isFile}}
|
connect(worker,
|
||||||
if({{paramName}} != NULL) {
|
&HttpRequestWorker::on_execution_finished,
|
||||||
input.add_var("{{paramName}}", *{{paramName}});
|
this,
|
||||||
}
|
&{{classname}}::{{nickname}}Callback);
|
||||||
{{/isFile}}{{/formParams}}
|
|
||||||
|
|
||||||
{{#bodyParams}}
|
worker->execute(&input);
|
||||||
{{#isContainer}}
|
}
|
||||||
QJsonArray* {{paramName}}Array = new QJsonArray();
|
|
||||||
toJsonArray((QList
|
|
||||||
<void
|
|
||||||
*>*){{paramName}}, {{paramName}}Array, QString("body"), QString("SWGUser*"));
|
|
||||||
|
|
||||||
QJsonDocument doc(*{{paramName}}Array);
|
void
|
||||||
QByteArray bytes = doc.toJson();
|
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
|
||||||
|
QString msg;
|
||||||
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = "Error: " + worker->error_str;
|
||||||
|
}
|
||||||
|
|
||||||
input.request_body.append(bytes);
|
{{#returnType}}{{#isListContainer}}
|
||||||
{{/isContainer}}
|
{{{returnType}}} output = {{{defaultResponse}}};
|
||||||
{{^isContainer}}
|
QString json(worker->response);
|
||||||
QString output = {{paramName}}.asJson();
|
QByteArray array (json.toStdString().c_str());
|
||||||
input.request_body.append(output);
|
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||||
{{/isContainer}}{{/bodyParams}}
|
QJsonArray jsonArray = doc.array();
|
||||||
|
|
||||||
{{#headerParams}}
|
foreach(QJsonValue obj, jsonArray) {
|
||||||
// TODO: add header support
|
{{{returnBaseType}}}* o = new {{returnBaseType}}();
|
||||||
{{/headerParams}}
|
QJsonObject jv = obj.toObject();
|
||||||
|
QJsonObject * ptr = (QJsonObject*)&jv;
|
||||||
|
o->fromJsonObject(*ptr);
|
||||||
|
output->append(o);
|
||||||
|
}
|
||||||
|
{{/isListContainer}}
|
||||||
|
|
||||||
connect(worker,
|
{{^isListContainer}}{{#returnTypeIsPrimitive}}
|
||||||
&HttpRequestWorker::on_execution_finished,
|
{{{returnType}}} output; // TODO add primitive output support
|
||||||
this,
|
{{/returnTypeIsPrimitive}}
|
||||||
&{{classname}}::{{nickname}}Callback);
|
{{#isMapContainer}}
|
||||||
|
{{{returnType}}} output = {{{defaultResponse}}};
|
||||||
|
|
||||||
worker->execute(&input);
|
QString json(worker->response);
|
||||||
}
|
QByteArray array (json.toStdString().c_str());
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||||
|
QJsonObject obj = doc.object();
|
||||||
|
|
||||||
void
|
foreach(QString key, obj.keys()) {
|
||||||
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
|
qint32* val;
|
||||||
QString msg;
|
setValue(&val, obj[key], "{{returnBaseType}}", "");
|
||||||
if (worker->error_type == QNetworkReply::NoError) {
|
output->insert(key, *val);
|
||||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
msg = "Error: " + worker->error_str;
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#returnType}}{{#isListContainer}}
|
|
||||||
{{{returnType}}} output = {{{defaultResponse}}};
|
|
||||||
QString json(worker->response);
|
|
||||||
QByteArray array (json.toStdString().c_str());
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
|
||||||
QJsonArray jsonArray = doc.array();
|
|
||||||
|
|
||||||
foreach(QJsonValue obj, jsonArray) {
|
|
||||||
{{{returnBaseType}}}* o = new {{returnBaseType}}();
|
|
||||||
QJsonObject jv = obj.toObject();
|
|
||||||
QJsonObject * ptr = (QJsonObject*)&jv;
|
|
||||||
o->fromJsonObject(*ptr);
|
|
||||||
output->append(o);
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
|
|
||||||
{{^isListContainer}}{{#returnTypeIsPrimitive}}
|
|
||||||
{{{returnType}}} output; // TODO add primitive output support
|
|
||||||
{{/returnTypeIsPrimitive}}
|
|
||||||
{{#isMapContainer}}
|
|
||||||
{{{returnType}}} output = {{{defaultResponse}}};
|
|
||||||
|
|
||||||
QString json(worker->response);
|
|
||||||
QByteArray array (json.toStdString().c_str());
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
|
||||||
QJsonObject obj = doc.object();
|
|
||||||
|
|
||||||
foreach(QString key, obj.keys()) {
|
|
||||||
qint32* val;
|
|
||||||
setValue(&val, obj[key], "{{returnBaseType}}", "");
|
|
||||||
output->insert(key, *val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{{/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}}
|
|
||||||
|
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
|
||||||
{{#returnType}}emit {{nickname}}Signal(output);{{/returnType}}
|
{{#returnType}}emit {{nickname}}Signal(output);{{/returnType}}
|
||||||
{{^returnType}}emit {{nickname}}Signal();{{/returnType}}
|
{{^returnType}}emit {{nickname}}Signal();{{/returnType}}
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
} /* namespace Swagger */
|
} /* namespace Swagger */
|
||||||
|
@ -6,15 +6,14 @@
|
|||||||
{{#imports}}{{{import}}}
|
{{#imports}}{{{import}}}
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
#include
|
#include <QObject>
|
||||||
<QObject>
|
|
||||||
|
|
||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
|
|
||||||
class {{classname}}: public QObject {
|
class {{classname}}: public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
{{classname}}();
|
{{classname}}();
|
||||||
{{classname}}(QString host, QString basePath);
|
{{classname}}(QString host, QString basePath);
|
||||||
~{{classname}}();
|
~{{classname}}();
|
||||||
@ -22,15 +21,14 @@
|
|||||||
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);
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
||||||
signals:
|
signals:
|
||||||
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
|
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -1,201 +1,166 @@
|
|||||||
#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 {
|
||||||
|
|
||||||
void
|
void
|
||||||
setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
||||||
if(value == NULL) {
|
if(value == NULL) {
|
||||||
// can't set value with a null pointer
|
// can't set value with a null pointer
|
||||||
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
|
*val = obj.toBool();
|
||||||
*>(value);
|
}
|
||||||
*val = obj.toBool();
|
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||||
}
|
qint32 *val = static_cast<qint32*>(value);
|
||||||
else if(QStringLiteral("qint32").compare(type) == 0) {
|
*val = obj.toInt();
|
||||||
qint32 *val = static_cast
|
}
|
||||||
<qint32
|
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||||
*>(value);
|
qint64 *val = static_cast<qint64*>(value);
|
||||||
*val = obj.toInt();
|
*val = obj.toVariant().toLongLong();
|
||||||
}
|
}
|
||||||
else if(QStringLiteral("qint64").compare(type) == 0) {
|
else if (QStringLiteral("QString").compare(type) == 0) {
|
||||||
qint64 *val = static_cast
|
QString **val = static_cast<QString**>(value);
|
||||||
<qint64
|
|
||||||
*>(value);
|
|
||||||
*val = obj.toVariant().toLongLong();
|
|
||||||
}
|
|
||||||
else if (QStringLiteral("QString").compare(type) == 0) {
|
|
||||||
QString **val = static_cast
|
|
||||||
<QString
|
|
||||||
**>(value);
|
|
||||||
|
|
||||||
if(val != NULL) {
|
if(val != NULL) {
|
||||||
if(!obj.isNull()) {
|
if(!obj.isNull()) {
|
||||||
// create a new value and return
|
// create a new value and return
|
||||||
delete *val;
|
delete *val;
|
||||||
*val = new QString(obj.toString());
|
*val = new QString(obj.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// set target to NULL
|
// set target to NULL
|
||||||
delete *val;
|
delete *val;
|
||||||
*val = NULL;
|
*val = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "Can't set value because the target pointer is NULL";
|
qDebug() << "Can't set value because the target pointer is NULL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(type.startsWith("SWG") && obj.isObject()) {
|
else if(type.startsWith("SWG") && obj.isObject()) {
|
||||||
// complex type
|
// complex type
|
||||||
QJsonObject jsonObj = obj.toObject();
|
QJsonObject jsonObj = obj.toObject();
|
||||||
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
|
QJsonArray arr = obj.toArray();
|
||||||
*>* output = new QList
|
foreach (const QJsonValue & jval, arr) {
|
||||||
<void
|
|
||||||
*>();
|
|
||||||
QJsonArray arr = obj.toArray();
|
|
||||||
foreach (const QJsonValue & jval, arr) {
|
|
||||||
if(complexType.startsWith("SWG")) {
|
if(complexType.startsWith("SWG")) {
|
||||||
// it's an object
|
// it's an object
|
||||||
SWGObject * val = (SWGObject*)create(complexType);
|
SWGObject * val = (SWGObject*)create(complexType);
|
||||||
QJsonObject t = jval.toObject();
|
QJsonObject t = jval.toObject();
|
||||||
|
|
||||||
val->fromJsonObject(t);
|
val->fromJsonObject(t);
|
||||||
output->append(val);
|
output->append(val);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// primitives
|
// primitives
|
||||||
if(QStringLiteral("qint32").compare(complexType) == 0) {
|
if(QStringLiteral("qint32").compare(complexType) == 0) {
|
||||||
qint32 val;
|
qint32 val;
|
||||||
setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral(""));
|
setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral(""));
|
||||||
output->append((void*)&val);
|
output->append((void*)&val);
|
||||||
}
|
}
|
||||||
else if(QStringLiteral("qint64").compare(complexType) == 0) {
|
else if(QStringLiteral("qint64").compare(complexType) == 0) {
|
||||||
qint64 val;
|
qint64 val;
|
||||||
setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral(""));
|
setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral(""));
|
||||||
output->append((void*)&val);
|
output->append((void*)&val);
|
||||||
}
|
}
|
||||||
else if(QStringLiteral("bool").compare(complexType) == 0) {
|
else if(QStringLiteral("bool").compare(complexType) == 0) {
|
||||||
bool val;
|
bool val;
|
||||||
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
|
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
|
||||||
output->append((void*)&val);
|
output->append((void*)&val);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
QList
|
|
||||||
<void
|
|
||||||
*> **val = static_cast
|
|
||||||
<QList
|
|
||||||
<void
|
|
||||||
*>**>(value);
|
|
||||||
delete *val;
|
|
||||||
*val = output;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
QList<void*> **val = static_cast<QList<void*>**>(value);
|
||||||
|
delete *val;
|
||||||
|
*val = output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
||||||
if(value == NULL) {
|
if(value == NULL) {
|
||||||
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) {
|
|
||||||
output->insert(name, *o);
|
output->insert(name, *o);
|
||||||
delete o;
|
delete o;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
output->empty();
|
output->empty();
|
||||||
foreach(QString key, o->keys()) {
|
foreach(QString key, o->keys()) {
|
||||||
output->insert(key, o->value(key));
|
output->insert(key, o->value(key));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(QStringLiteral("QString").compare(type) == 0) {
|
|
||||||
QString* str = static_cast
|
|
||||||
<QString
|
|
||||||
*>(value);
|
|
||||||
output->insert(name, QJsonValue(*str));
|
|
||||||
}
|
|
||||||
else if(QStringLiteral("qint32").compare(type) == 0) {
|
|
||||||
qint32* str = static_cast
|
|
||||||
<qint32
|
|
||||||
*>(value);
|
|
||||||
output->insert(name, QJsonValue(*str));
|
|
||||||
}
|
|
||||||
else if(QStringLiteral("qint64").compare(type) == 0) {
|
|
||||||
qint64* str = static_cast
|
|
||||||
<qint64
|
|
||||||
*>(value);
|
|
||||||
output->insert(name, QJsonValue(*str));
|
|
||||||
}
|
|
||||||
else if(QStringLiteral("bool").compare(type) == 0) {
|
|
||||||
bool* str = static_cast
|
|
||||||
<bool
|
|
||||||
*>(value);
|
|
||||||
output->insert(name, QJsonValue(*str));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("QString").compare(type) == 0) {
|
||||||
|
QString* str = static_cast<QString*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||||
|
qint32* str = static_cast<qint32*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||||
|
qint64* str = static_cast<qint64*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("bool").compare(type) == 0) {
|
||||||
|
bool* str = static_cast<bool*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toJsonArray(QList
|
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||||
<void
|
foreach(void* obj, *value) {
|
||||||
*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
QJsonObject element;
|
||||||
foreach(void* obj, *value) {
|
|
||||||
QJsonObject element;
|
|
||||||
|
|
||||||
toJsonValue(NULL, obj, &element, innerType);
|
toJsonValue(NULL, obj, &element, innerType);
|
||||||
output->append(element);
|
output->append(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
stringValue(QString* value) {
|
stringValue(QString* value) {
|
||||||
QString* str = static_cast
|
QString* str = static_cast<QString*>(value);
|
||||||
<QString
|
return QString(*str);
|
||||||
*>(value);
|
}
|
||||||
return QString(*str);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
stringValue(qint32 value) {
|
stringValue(qint32 value) {
|
||||||
return QString::number(value);
|
return QString::number(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
stringValue(qint64 value) {
|
stringValue(qint64 value) {
|
||||||
return QString::number(value);
|
return QString::number(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
stringValue(bool value) {
|
stringValue(bool value) {
|
||||||
return QString(value ? "true" : "false");
|
return QString(value ? "true" : "false");
|
||||||
}
|
}
|
||||||
} /* namespace Swagger */
|
} /* namespace Swagger */
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
#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);
|
||||||
QString stringValue(qint32 value);
|
QString stringValue(qint32 value);
|
||||||
QString stringValue(qint64 value);
|
QString stringValue(qint64 value);
|
||||||
QString stringValue(bool value);
|
QString stringValue(bool value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SWGHELPERS_H
|
#endif // SWGHELPERS_H
|
||||||
|
@ -1,114 +1,109 @@
|
|||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
#include "{{classname}}.h"
|
#include "{{classname}}.h"
|
||||||
|
|
||||||
#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 {
|
||||||
|
|
||||||
|
|
||||||
{{classname}}::{{classname}}(QString* json) {
|
{{classname}}::{{classname}}(QString* json) {
|
||||||
init();
|
init();
|
||||||
this->fromJson(*json);
|
this->fromJson(*json);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{classname}}::{{classname}}() {
|
{{classname}}::{{classname}}() {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
{{classname}}::~{{classname}}() {
|
{{classname}}::~{{classname}}() {
|
||||||
this->cleanup();
|
this->cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::init() {
|
{{classname}}::init() {
|
||||||
{{#vars}}{{name}} = {{{defaultValue}}};
|
{{#vars}}{{name}} = {{{defaultValue}}};
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::cleanup() {
|
{{classname}}::cleanup() {
|
||||||
{{#vars}}{{#complexType}}if({{name}} != NULL) {
|
{{#vars}}{{#complexType}}if({{name}} != NULL) {
|
||||||
{{#isContainer}}QList<{{complexType}}*>* arr = {{name}};
|
{{#isContainer}}QList<{{complexType}}*>* arr = {{name}};
|
||||||
foreach({{complexType}}* o, *arr) {
|
foreach({{complexType}}* o, *arr) {
|
||||||
delete o;
|
delete o;
|
||||||
}
|
}
|
||||||
{{/isContainer}}delete {{name}};
|
{{/isContainer}}delete {{name}};
|
||||||
}{{/complexType}}
|
}{{/complexType}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{classname}}*
|
{{classname}}*
|
||||||
{{classname}}::fromJson(QString &json) {
|
{{classname}}::fromJson(QString &json) {
|
||||||
QByteArray array (json.toStdString().c_str());
|
QByteArray array (json.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);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::fromJsonObject(QJsonObject &pJson) {
|
{{classname}}::fromJsonObject(QJsonObject &pJson) {
|
||||||
{{#vars}}setValue(&{{name}}, pJson["{{name}}"], "{{baseType}}", "{{complexType}}");
|
{{#vars}}setValue(&{{name}}, pJson["{{name}}"], "{{baseType}}", "{{complexType}}");
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
{{classname}}::asJson ()
|
{{classname}}::asJson ()
|
||||||
{
|
{
|
||||||
QJsonObject* obj = this->asJsonObject();
|
QJsonObject* obj = this->asJsonObject();
|
||||||
|
|
||||||
|
QJsonDocument doc(*obj);
|
||||||
|
QByteArray bytes = doc.toJson();
|
||||||
|
return QString(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
QJsonDocument doc(*obj);
|
QJsonObject*
|
||||||
QByteArray bytes = doc.toJson();
|
{{classname}}::asJsonObject() {
|
||||||
return QString(bytes);
|
QJsonObject* obj = new QJsonObject();
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject*
|
|
||||||
{{classname}}::asJsonObject() {
|
|
||||||
QJsonObject* obj = new QJsonObject();
|
|
||||||
{{#vars}}{{#complexType}}
|
{{#vars}}{{#complexType}}
|
||||||
{{^isContainer}}{{#complexType}}
|
{{^isContainer}}{{#complexType}}
|
||||||
toJsonValue(QString("{{name}}"), {{name}}, obj, QString("{{complexType}}"));
|
toJsonValue(QString("{{name}}"), {{name}}, obj, QString("{{complexType}}"));
|
||||||
{{/complexType}}{{^complexType}}
|
{{/complexType}}{{^complexType}}
|
||||||
else if({{name}} != NULL && *{{name}} != NULL) {
|
else if({{name}} != NULL && *{{name}} != NULL) {
|
||||||
obj->insert("{{name}}", QJsonValue(*{{name}}));
|
obj->insert("{{name}}", QJsonValue(*{{name}}));
|
||||||
}{{/complexType}}
|
}{{/complexType}}
|
||||||
{{/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}}
|
||||||
{{/complexType}}{{^complexType}}obj->insert("{{name}}", QJsonValue({{name}}));{{/complexType}}
|
{{/complexType}}{{^complexType}}obj->insert("{{name}}", QJsonValue({{name}}));{{/complexType}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{{datatype}}}
|
{{{datatype}}}
|
||||||
{{classname}}::{{getter}}() {
|
{{classname}}::{{getter}}() {
|
||||||
return {{name}};
|
return {{name}};
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
{{classname}}::{{setter}}({{{datatype}}} {{name}}) {
|
{{classname}}::{{setter}}({{{datatype}}} {{name}}) {
|
||||||
this->{{name}} = {{name}};
|
this->{{name}} = {{name}};
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
|
|
||||||
} /* namespace Swagger */
|
} /* namespace Swagger */
|
||||||
|
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
@ -1,48 +1,47 @@
|
|||||||
{{#models}}{{#model}}/*
|
{{#models}}{{#model}}/*
|
||||||
* {{classname}}.h
|
* {{classname}}.h
|
||||||
*
|
*
|
||||||
* {{description}}
|
* {{description}}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef {{classname}}_H_
|
#ifndef {{classname}}_H_
|
||||||
#define {{classname}}_H_
|
#define {{classname}}_H_
|
||||||
|
|
||||||
#include
|
#include <QJsonObject>
|
||||||
<QJsonObject>
|
|
||||||
|
|
||||||
{{/model}}{{/models}}
|
{{/model}}{{/models}}
|
||||||
{{#imports}}{{{import}}}
|
{{#imports}}{{{import}}}
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
#include "SWGObject.h"
|
#include "SWGObject.h"
|
||||||
|
|
||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
|
|
||||||
class {{classname}}: public SWGObject {
|
class {{classname}}: public SWGObject {
|
||||||
public:
|
public:
|
||||||
{{classname}}();
|
{{classname}}();
|
||||||
{{classname}}(QString* json);
|
{{classname}}(QString* json);
|
||||||
virtual ~{{classname}}();
|
virtual ~{{classname}}();
|
||||||
void init();
|
void init();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
QString asJson ();
|
QString asJson ();
|
||||||
QJsonObject* asJsonObject();
|
QJsonObject* asJsonObject();
|
||||||
void fromJsonObject(QJsonObject &json);
|
void fromJsonObject(QJsonObject &json);
|
||||||
{{classname}}* fromJson(QString &jsonString);
|
{{classname}}* fromJson(QString &jsonString);
|
||||||
|
|
||||||
{{#vars}}{{{datatype}}} {{getter}}();
|
{{#vars}}{{{datatype}}} {{getter}}();
|
||||||
void {{setter}}({{{datatype}}} {{name}});
|
void {{setter}}({{{datatype}}} {{name}});
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
{{#vars}}{{{datatype}}} {{name}};
|
{{#vars}}{{{datatype}}} {{name}};
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace Swagger */
|
} /* namespace Swagger */
|
||||||
|
|
||||||
#endif /* {{classname}}_H_ */
|
#endif /* {{classname}}_H_ */
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
@ -1,62 +1,58 @@
|
|||||||
{{#models}}{{#model}}/*
|
{{#models}}{{#model}}/*
|
||||||
* {{classname}}.h
|
* {{classname}}.h
|
||||||
*
|
*
|
||||||
* {{description}}
|
* {{description}}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#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
|
#include "{{prefix}}Helpers.h"
|
||||||
<FSystem.h>
|
#include "{{prefix}}Object.h"
|
||||||
#include
|
|
||||||
<FWebJson.h>
|
|
||||||
#include "{{prefix}}Helpers.h"
|
|
||||||
#include "{{prefix}}Object.h"
|
|
||||||
|
|
||||||
using namespace Tizen::Web::Json;
|
using namespace Tizen::Web::Json;
|
||||||
|
|
||||||
{{/model}}{{/models}}
|
{{/model}}{{/models}}
|
||||||
{{#imports}}{{{import}}}
|
{{#imports}}{{{import}}}
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
|
|
||||||
class {{classname}}: public {{prefix}}Object {
|
class {{classname}}: public {{prefix}}Object {
|
||||||
public:
|
public:
|
||||||
{{classname}}();
|
{{classname}}();
|
||||||
{{classname}}(String* json);
|
{{classname}}(String* json);
|
||||||
virtual ~{{classname}}();
|
virtual ~{{classname}}();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
String asJson ();
|
String asJson ();
|
||||||
|
|
||||||
JsonObject* asJsonObject();
|
JsonObject* asJsonObject();
|
||||||
|
|
||||||
void fromJsonObject(IJsonValue* json);
|
void fromJsonObject(IJsonValue* json);
|
||||||
|
|
||||||
{{classname}}* fromJson(String* obj);
|
{{classname}}* fromJson(String* obj);
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{datatype}} {{getter}}();
|
{{datatype}} {{getter}}();
|
||||||
void {{setter}}({{datatype}} {{name}});
|
void {{setter}}({{datatype}} {{name}});
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
{{#vars}}{{datatype}} {{name}};
|
{{#vars}}{{datatype}} {{name}};
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace Swagger */
|
} /* namespace Swagger */
|
||||||
|
|
||||||
#endif /* {{classname}}_H_ */
|
#endif /* {{classname}}_H_ */
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
@ -2,29 +2,28 @@
|
|||||||
#define ModelFactory_H_
|
#define ModelFactory_H_
|
||||||
|
|
||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
#include "{{classname}}.h"{{/model}}{{/models}}
|
#include "{{classname}}.h"{{/model}}{{/models}}
|
||||||
|
|
||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
inline void* create(QString type) {
|
inline void* create(QString type) {
|
||||||
{{#models}}{{#model}}if(QString("{{classname}}").compare(type) == 0) {
|
{{#models}}{{#model}}if(QString("{{classname}}").compare(type) == 0) {
|
||||||
return new {{classname}}();
|
return new {{classname}}();
|
||||||
}
|
}
|
||||||
{{/model}}{{/models}}
|
{{/model}}{{/models}}
|
||||||
return NULL;
|
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")) {
|
return new QString();
|
||||||
return new QString();
|
}
|
||||||
}
|
return NULL;
|
||||||
return NULL;
|
}
|
||||||
}
|
|
||||||
} /* namespace Swagger */
|
} /* namespace Swagger */
|
||||||
|
|
||||||
#endif /* ModelFactory_H_ */
|
#endif /* ModelFactory_H_ */
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
#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:
|
||||||
virtual QJsonObject* asJsonObject() {
|
virtual QJsonObject* asJsonObject() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
virtual ~SWGObject() {}
|
virtual ~SWGObject() {}
|
||||||
virtual SWGObject* fromJson(QString &jsonString) {
|
virtual SWGObject* fromJson(QString &jsonString) {
|
||||||
Q_UNUSED(jsonString);
|
Q_UNUSED(jsonString);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
virtual void fromJsonObject(QJsonObject &json) {
|
virtual void fromJsonObject(QJsonObject &json) {
|
||||||
Q_UNUSED(json);
|
Q_UNUSED(json);
|
||||||
}
|
}
|
||||||
virtual QString asJson() {
|
virtual QString asJson() {
|
||||||
return QString("");
|
return QString("");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _{{prefix}}_OBJECT_H_ */
|
#endif /* _{{prefix}}_OBJECT_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user