forked from loafle/openapi-generator-original
roll back qt5cpp template
This commit is contained in:
parent
263b4080ee
commit
6253bbff3d
@ -2,26 +2,23 @@
|
|||||||
#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}}
|
{{#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();
|
||||||
@ -122,10 +117,10 @@
|
|||||||
&{{classname}}::{{nickname}}Callback);
|
&{{classname}}::{{nickname}}Callback);
|
||||||
|
|
||||||
worker->execute(&input);
|
worker->execute(&input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
|
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
if (worker->error_type == QNetworkReply::NoError) {
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||||
@ -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}}
|
||||||
@ -181,7 +175,7 @@
|
|||||||
|
|
||||||
{{#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,43 +1,32 @@
|
|||||||
#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
|
|
||||||
*>(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,25 +88,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QList
|
QList<void*> **val = static_cast<QList<void*>**>(value);
|
||||||
<void
|
|
||||||
*> **val = static_cast
|
|
||||||
<QList
|
|
||||||
<void
|
|
||||||
*>**>(value);
|
|
||||||
delete *val;
|
delete *val;
|
||||||
*val = output;
|
*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) {
|
||||||
@ -139,63 +116,51 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
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
|
|
||||||
*>(value);
|
|
||||||
return QString(*str);
|
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,41 +1,37 @@
|
|||||||
{{#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) {
|
||||||
@ -44,35 +40,35 @@
|
|||||||
{{/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);
|
QJsonDocument doc(*obj);
|
||||||
QByteArray bytes = doc.toJson();
|
QByteArray bytes = doc.toJson();
|
||||||
return QString(bytes);
|
return QString(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject*
|
QJsonObject*
|
||||||
{{classname}}::asJsonObject() {
|
{{classname}}::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
{{#vars}}{{#complexType}}
|
{{#vars}}{{#complexType}}
|
||||||
{{^isContainer}}{{#complexType}}
|
{{^isContainer}}{{#complexType}}
|
||||||
@ -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}}
|
||||||
@ -93,22 +88,22 @@
|
|||||||
{{/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,26 +1,25 @@
|
|||||||
{{#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}}();
|
||||||
@ -36,13 +35,13 @@
|
|||||||
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,34 +1,30 @@
|
|||||||
{{#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}}();
|
||||||
@ -50,13 +46,13 @@
|
|||||||
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,10 +1,9 @@
|
|||||||
#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;
|
||||||
@ -20,6 +19,6 @@
|
|||||||
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