* Add CPP_NAMESPACE option

* update mustache template to exploit cppNamespace option

* update sample files

* correction : missing namespace replacement in template
This commit is contained in:
sabras75 2017-04-28 16:19:37 +02:00 committed by wing328
parent 0792933c7e
commit 994e4fd8ff
45 changed files with 187 additions and 60 deletions

View File

@ -1,9 +1,6 @@
package io.swagger.codegen.languages; package io.swagger.codegen.languages;
import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.*;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty; import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DateProperty; import io.swagger.models.properties.DateProperty;
@ -27,6 +24,9 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
public static final String CPP_NAMESPACE = "cppNamespace";
public static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api).";
protected final String PREFIX = "SWG"; protected final String PREFIX = "SWG";
protected Set<String> foundationClasses = new HashSet<String>(); protected Set<String> foundationClasses = new HashSet<String>();
// source folder where to write the files // source folder where to write the files
@ -34,6 +34,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
protected String apiVersion = "1.0.0"; protected String apiVersion = "1.0.0";
protected Map<String, String> namespaces = new HashMap<String, String>(); protected Map<String, String> namespaces = new HashMap<String, String>();
protected Set<String> systemIncludes = new HashSet<String>(); protected Set<String> systemIncludes = new HashSet<String>();
protected String cppNamespace = "Swagger";
public Qt5CPPGenerator() { public Qt5CPPGenerator() {
super(); super();
@ -74,6 +75,9 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
*/ */
embeddedTemplateDir = templateDir = "qt5cpp"; embeddedTemplateDir = templateDir = "qt5cpp";
// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
/* /*
* Reserved words. Override this with reserved words specific to your language * Reserved words. Override this with reserved words specific to your language
*/ */
@ -90,6 +94,11 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("apiVersion", apiVersion); additionalProperties.put("apiVersion", apiVersion);
additionalProperties().put("prefix", PREFIX); additionalProperties().put("prefix", PREFIX);
// Write defaults namespace in properties so that it can be accessible in templates.
// At this point command line has not been parsed so if value is given
// in command line it will superseed this content
additionalProperties.put("cppNamespace",cppNamespace);
/* /*
* Language Specific Primitives. These types will not trigger imports by * Language Specific Primitives. These types will not trigger imports by
* the client generator * the client generator
@ -148,6 +157,24 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
systemIncludes.add("QByteArray"); systemIncludes.add("QByteArray");
} }
protected void addOption(String key, String description, String defaultValue) {
CliOption option = new CliOption(key, description);
if (defaultValue != null)
option.defaultValue(defaultValue);
cliOptions.add(option);
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("cppNamespace")){
cppNamespace = (String) additionalProperties.get("cppNamespace");
}
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
}
/** /**
* Configures the type of generator. * Configures the type of generator.
* *
@ -266,6 +293,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
} }
} }
@Override @Override
public String toDefaultValue(Property p) { public String toDefaultValue(Property p) {
if (p instanceof StringProperty) { if (p instanceof StringProperty) {
@ -310,7 +338,6 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
return "NULL"; return "NULL";
} }
/** /**
* Optional - swagger type conversion. This is used to map swagger types in a `Property` into * Optional - swagger type conversion. This is used to map swagger types in a `Property` into
* either language specific types via `typeMapping` or into complex models if there is not a mapping. * either language specific types via `typeMapping` or into complex models if there is not a mapping.

View File

@ -6,6 +6,10 @@
#include <QBuffer> #include <QBuffer>
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
HttpRequestInput::HttpRequestInput() { HttpRequestInput::HttpRequestInput() {
initialize(); initialize();
} }
@ -298,3 +302,7 @@ void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
emit on_execution_finished(this); emit on_execution_finished(this);
} }
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@ -16,6 +16,9 @@
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART}; enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class SWGHttpRequestInputFileElement { class SWGHttpRequestInputFileElement {
@ -73,4 +76,8 @@ private slots:
}; };
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif // HTTPREQUESTWORKER_H #endif // HTTPREQUESTWORKER_H

View File

@ -6,7 +6,10 @@
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
namespace Swagger { {{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
{{classname}}::{{classname}}() {} {{classname}}::{{classname}}() {}
{{classname}}::~{{classname}}() {} {{classname}}::~{{classname}}() {}
@ -178,4 +181,7 @@ void
} }
{{/operation}} {{/operation}}
{{/operations}} {{/operations}}
} /* namespace Swagger */
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@ -9,7 +9,9 @@
#include <QObject> #include <QObject>
namespace Swagger { {{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{classname}}: public QObject { class {{classname}}: public QObject {
Q_OBJECT Q_OBJECT
@ -31,5 +33,8 @@ signals:
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}}); {{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
{{/operation}}{{/operations}} {{/operation}}{{/operations}}
}; };
{{#cppNamespaceDeclarations}}
} }
{{/cppNamespaceDeclarations}}
#endif #endif

View File

@ -7,7 +7,10 @@
#include <QJsonValue> #include <QJsonValue>
#include <QDateTime> #include <QDateTime>
namespace Swagger {
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
void void
setValue(void* value, QJsonValue obj, QString type, QString complexType) { setValue(void* value, QJsonValue obj, QString type, QString complexType) {
@ -119,7 +122,7 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
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*)::{{cppNamespace}}::create(type);
if(so != nullptr) { if(so != nullptr) {
so->fromJsonObject(jsonObj); so->fromJsonObject(jsonObj);
SWGObject **val = static_cast<SWGObject**>(value); SWGObject **val = static_cast<SWGObject**>(value);
@ -279,4 +282,7 @@ QString
stringValue(bool value) { stringValue(bool value) {
return QString(value ? "true" : "false"); return QString(value ? "true" : "false");
} }
} /* namespace Swagger */
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@ -4,7 +4,10 @@
#include <QJsonValue> #include <QJsonValue>
namespace Swagger { {{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
void setValue(void* value, QJsonValue obj, QString type, QString complexType); 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); void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
@ -13,6 +16,9 @@ namespace Swagger {
QString stringValue(qint32 value); QString stringValue(qint32 value);
QString stringValue(qint64 value); QString stringValue(qint64 value);
QString stringValue(bool value); QString stringValue(bool value);
{{#cppNamespaceDeclarations}}
} }
{{/cppNamespaceDeclarations}}
#endif // SWGHELPERS_H #endif // SWGHELPERS_H

View File

@ -9,8 +9,9 @@
#include <QObject> #include <QObject>
#include <QDebug> #include <QDebug>
namespace Swagger { {{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
{{classname}}::{{classname}}(QString* json) { {{classname}}::{{classname}}(QString* json) {
init(); init();
@ -57,10 +58,10 @@ void
void void
{{classname}}::fromJsonObject(QJsonObject &pJson) { {{classname}}::fromJsonObject(QJsonObject &pJson) {
{{#vars}} {{#vars}}
{{^isContainer}}::Swagger::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}} {{^isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}}
{{#isContainer}} {{#isContainer}}
{{#complexType}}::Swagger::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/complexType}} {{#complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/complexType}}
{{^complexType}}::Swagger::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}");{{/complexType}} {{^complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}");{{/complexType}}
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}
} }
@ -107,8 +108,9 @@ void
{{/vars}} {{/vars}}
{{#cppNamespaceDeclarations}}
} /* namespace Swagger */ }
{{/cppNamespaceDeclarations}}
{{/model}} {{/model}}
{{/models}} {{/models}}

View File

@ -17,7 +17,9 @@
#include "SWGObject.h" #include "SWGObject.h"
{{#models}}{{#model}} {{#models}}{{#model}}
namespace Swagger { {{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{classname}}: public SWGObject { class {{classname}}: public SWGObject {
public: public:
@ -44,7 +46,9 @@ private:
{{/vars}} {{/vars}}
}; };
} /* namespace Swagger */ {{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif /* {{classname}}_H_ */ #endif /* {{classname}}_H_ */
{{/model}} {{/model}}

View File

@ -22,7 +22,10 @@ using namespace Tizen::Web::Json;
{{/imports}} {{/imports}}
{{#models}}{{#model}} {{#models}}{{#model}}
namespace Swagger {
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{classname}}: public {{prefix}}Object { class {{classname}}: public {{prefix}}Object {
public: public:
@ -52,7 +55,9 @@ private:
{{/vars}} {{/vars}}
}; };
} /* namespace Swagger */ {{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif /* {{classname}}_H_ */ #endif /* {{classname}}_H_ */
{{/model}} {{/model}}

View File

@ -5,7 +5,10 @@
{{#models}}{{#model}} {{#models}}{{#model}}
#include "{{classname}}.h"{{/model}}{{/models}} #include "{{classname}}.h"{{/model}}{{/models}}
namespace Swagger { {{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
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}}();
@ -25,6 +28,9 @@ namespace Swagger {
} }
return nullptr; return nullptr;
} }
} /* namespace Swagger */
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif /* ModelFactory_H_ */ #endif /* ModelFactory_H_ */

View File

@ -4,6 +4,10 @@
#include <QJsonValue> #include <QJsonValue>
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{prefix}}Object { class {{prefix}}Object {
public: public:
virtual QJsonObject* asJsonObject() { virtual QJsonObject* asJsonObject() {
@ -22,4 +26,8 @@ class {{prefix}}Object {
} }
}; };
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif /* _{{prefix}}_OBJECT_H_ */ #endif /* _{{prefix}}_OBJECT_H_ */

View File

@ -3,6 +3,7 @@ package io.swagger.codegen.options;
import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenConstants;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import io.swagger.codegen.languages.Qt5CPPGenerator;
import java.util.Map; import java.util.Map;
@ -10,6 +11,7 @@ public class Qt5CPPOptionsProvider implements OptionsProvider {
public static final String SORT_PARAMS_VALUE = "false"; public static final String SORT_PARAMS_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
public static final String CPP_NAMESPACE_VALUE = "Swagger";
@Override @Override
@ -23,6 +25,7 @@ public class Qt5CPPOptionsProvider implements OptionsProvider {
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
.put(Qt5CPPGenerator.CPP_NAMESPACE, CPP_NAMESPACE_VALUE)
.build(); .build();
} }

View File

@ -18,6 +18,7 @@
#include <QJsonDocument> #include <QJsonDocument>
namespace Swagger { namespace Swagger {
SWGFakeApi::SWGFakeApi() {} SWGFakeApi::SWGFakeApi() {}
SWGFakeApi::~SWGFakeApi() {} SWGFakeApi::~SWGFakeApi() {}
@ -69,4 +70,5 @@ SWGFakeApi::testCodeInject */ &#39; &quot; &#x3D;end \r\n \n \rCallback(HttpReq
emit testCodeInject */ &#39; &quot; &#x3D;end \r\n \n \rSignal(); emit testCodeInject */ &#39; &quot; &#x3D;end \r\n \n \rSignal();
} }
} /* namespace Swagger */
}

View File

@ -41,5 +41,6 @@ signals:
void testCodeInject */ &#39; &quot; &#x3D;end \r\n \n \rSignal(); void testCodeInject */ &#39; &quot; &#x3D;end \r\n \n \rSignal();
}; };
} }
#endif #endif

View File

@ -18,6 +18,7 @@
#include <QJsonValue> #include <QJsonValue>
#include <QDateTime> #include <QDateTime>
namespace Swagger { namespace Swagger {
void void
@ -130,7 +131,7 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
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 != nullptr) { if(so != nullptr) {
so->fromJsonObject(jsonObj); so->fromJsonObject(jsonObj);
SWGObject **val = static_cast<SWGObject**>(value); SWGObject **val = static_cast<SWGObject**>(value);
@ -290,4 +291,5 @@ QString
stringValue(bool value) { stringValue(bool value) {
return QString(value ? "true" : "false"); return QString(value ? "true" : "false");
} }
} /* namespace Swagger */
}

View File

@ -16,6 +16,7 @@
#include <QJsonValue> #include <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*>* 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); void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
@ -24,6 +25,7 @@ namespace Swagger {
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

View File

@ -17,6 +17,8 @@
#include <QBuffer> #include <QBuffer>
namespace Swagger {
HttpRequestInput::HttpRequestInput() { HttpRequestInput::HttpRequestInput() {
initialize(); initialize();
} }
@ -309,3 +311,5 @@ void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
emit on_execution_finished(this); emit on_execution_finished(this);
} }
}

View File

@ -27,6 +27,7 @@
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART}; enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
namespace Swagger {
class SWGHttpRequestInputFileElement { class SWGHttpRequestInputFileElement {
@ -84,4 +85,6 @@ private slots:
}; };
}
#endif // HTTPREQUESTWORKER_H #endif // HTTPREQUESTWORKER_H

View File

@ -17,6 +17,7 @@
#include "SWGReturn.h" #include "SWGReturn.h"
namespace Swagger { namespace Swagger {
inline void* create(QString type) { inline void* create(QString type) {
if(QString("SWGReturn").compare(type) == 0) { if(QString("SWGReturn").compare(type) == 0) {
return new SWGReturn(); return new SWGReturn();
@ -36,6 +37,7 @@ namespace Swagger {
} }
return nullptr; return nullptr;
} }
} /* namespace Swagger */
}
#endif /* ModelFactory_H_ */ #endif /* ModelFactory_H_ */

View File

@ -15,6 +15,8 @@
#include <QJsonValue> #include <QJsonValue>
namespace Swagger {
class SWGObject { class SWGObject {
public: public:
virtual QJsonObject* asJsonObject() { virtual QJsonObject* asJsonObject() {
@ -33,4 +35,6 @@ class SWGObject {
} }
}; };
}
#endif /* _SWG_OBJECT_H_ */ #endif /* _SWG_OBJECT_H_ */

View File

@ -22,7 +22,6 @@
namespace Swagger { namespace Swagger {
SWGReturn::SWGReturn(QString* json) { SWGReturn::SWGReturn(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
@ -89,6 +88,5 @@ SWGReturn::setReturn(qint32 return) {
} }
}
} /* namespace Swagger */

View File

@ -49,6 +49,6 @@ private:
qint32 return; qint32 return;
}; };
} /* namespace Swagger */ }
#endif /* SWGReturn_H_ */ #endif /* SWGReturn_H_ */

View File

@ -22,7 +22,6 @@
namespace Swagger { namespace Swagger {
SWGCategory::SWGCategory(QString* json) { SWGCategory::SWGCategory(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
@ -106,6 +105,5 @@ SWGCategory::setName(QString* name) {
} }
}
} /* namespace Swagger */

View File

@ -54,6 +54,6 @@ private:
QString* name; QString* name;
}; };
} /* namespace Swagger */ }
#endif /* SWGCategory_H_ */ #endif /* SWGCategory_H_ */

View File

@ -18,6 +18,7 @@
#include <QJsonValue> #include <QJsonValue>
#include <QDateTime> #include <QDateTime>
namespace Swagger { namespace Swagger {
void void
@ -130,7 +131,7 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
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 != nullptr) { if(so != nullptr) {
so->fromJsonObject(jsonObj); so->fromJsonObject(jsonObj);
SWGObject **val = static_cast<SWGObject**>(value); SWGObject **val = static_cast<SWGObject**>(value);
@ -290,4 +291,5 @@ QString
stringValue(bool value) { stringValue(bool value) {
return QString(value ? "true" : "false"); return QString(value ? "true" : "false");
} }
} /* namespace Swagger */
}

View File

@ -16,6 +16,7 @@
#include <QJsonValue> #include <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*>* 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); void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
@ -24,6 +25,7 @@ namespace Swagger {
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

View File

@ -17,6 +17,8 @@
#include <QBuffer> #include <QBuffer>
namespace Swagger {
HttpRequestInput::HttpRequestInput() { HttpRequestInput::HttpRequestInput() {
initialize(); initialize();
} }
@ -309,3 +311,5 @@ void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
emit on_execution_finished(this); emit on_execution_finished(this);
} }
}

View File

@ -27,6 +27,7 @@
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART}; enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
namespace Swagger {
class SWGHttpRequestInputFileElement { class SWGHttpRequestInputFileElement {
@ -84,4 +85,6 @@ private slots:
}; };
}
#endif // HTTPREQUESTWORKER_H #endif // HTTPREQUESTWORKER_H

View File

@ -21,6 +21,7 @@
#include "SWGUser.h" #include "SWGUser.h"
namespace Swagger { namespace Swagger {
inline void* create(QString type) { inline void* create(QString type) {
if(QString("SWGCategory").compare(type) == 0) { if(QString("SWGCategory").compare(type) == 0) {
return new SWGCategory(); return new SWGCategory();
@ -52,6 +53,7 @@ namespace Swagger {
} }
return nullptr; return nullptr;
} }
} /* namespace Swagger */
}
#endif /* ModelFactory_H_ */ #endif /* ModelFactory_H_ */

View File

@ -15,6 +15,8 @@
#include <QJsonValue> #include <QJsonValue>
namespace Swagger {
class SWGObject { class SWGObject {
public: public:
virtual QJsonObject* asJsonObject() { virtual QJsonObject* asJsonObject() {
@ -33,4 +35,6 @@ class SWGObject {
} }
}; };
}
#endif /* _SWG_OBJECT_H_ */ #endif /* _SWG_OBJECT_H_ */

View File

@ -22,7 +22,6 @@
namespace Swagger { namespace Swagger {
SWGOrder::SWGOrder(QString* json) { SWGOrder::SWGOrder(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
@ -165,6 +164,5 @@ SWGOrder::setComplete(bool complete) {
} }
}
} /* namespace Swagger */

View File

@ -71,6 +71,6 @@ private:
bool complete; bool complete;
}; };
} /* namespace Swagger */ }
#endif /* SWGOrder_H_ */ #endif /* SWGOrder_H_ */

View File

@ -22,7 +22,6 @@
namespace Swagger { namespace Swagger {
SWGPet::SWGPet(QString* json) { SWGPet::SWGPet(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
@ -190,6 +189,5 @@ SWGPet::setStatus(QString* status) {
} }
}
} /* namespace Swagger */

View File

@ -73,6 +73,6 @@ private:
QString* status; QString* status;
}; };
} /* namespace Swagger */ }
#endif /* SWGPet_H_ */ #endif /* SWGPet_H_ */

View File

@ -18,6 +18,7 @@
#include <QJsonDocument> #include <QJsonDocument>
namespace Swagger { namespace Swagger {
SWGPetApi::SWGPetApi() {} SWGPetApi::SWGPetApi() {}
SWGPetApi::~SWGPetApi() {} SWGPetApi::~SWGPetApi() {}
@ -481,4 +482,5 @@ SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
emit uploadFileSignal(); emit uploadFileSignal();
} }
} /* namespace Swagger */
}

View File

@ -64,5 +64,6 @@ signals:
void uploadFileSignal(); void uploadFileSignal();
}; };
} }
#endif #endif

View File

@ -18,6 +18,7 @@
#include <QJsonDocument> #include <QJsonDocument>
namespace Swagger { namespace Swagger {
SWGStoreApi::SWGStoreApi() {} SWGStoreApi::SWGStoreApi() {}
SWGStoreApi::~SWGStoreApi() {} SWGStoreApi::~SWGStoreApi() {}
@ -210,4 +211,5 @@ SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
emit placeOrderSignal(output); emit placeOrderSignal(output);
} }
} /* namespace Swagger */
}

View File

@ -52,5 +52,6 @@ signals:
void placeOrderSignal(SWGOrder* summary); void placeOrderSignal(SWGOrder* summary);
}; };
} }
#endif #endif

View File

@ -22,7 +22,6 @@
namespace Swagger { namespace Swagger {
SWGTag::SWGTag(QString* json) { SWGTag::SWGTag(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
@ -106,6 +105,5 @@ SWGTag::setName(QString* name) {
} }
}
} /* namespace Swagger */

View File

@ -54,6 +54,6 @@ private:
QString* name; QString* name;
}; };
} /* namespace Swagger */ }
#endif /* SWGTag_H_ */ #endif /* SWGTag_H_ */

View File

@ -22,7 +22,6 @@
namespace Swagger { namespace Swagger {
SWGUser::SWGUser(QString* json) { SWGUser::SWGUser(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
@ -205,6 +204,5 @@ SWGUser::setUserStatus(qint32 user_status) {
} }
}
} /* namespace Swagger */

View File

@ -78,6 +78,6 @@ private:
qint32 user_status; qint32 user_status;
}; };
} /* namespace Swagger */ }
#endif /* SWGUser_H_ */ #endif /* SWGUser_H_ */

View File

@ -18,6 +18,7 @@
#include <QJsonDocument> #include <QJsonDocument>
namespace Swagger { namespace Swagger {
SWGUserApi::SWGUserApi() {} SWGUserApi::SWGUserApi() {}
SWGUserApi::~SWGUserApi() {} SWGUserApi::~SWGUserApi() {}
@ -385,4 +386,5 @@ SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
emit updateUserSignal(); emit updateUserSignal();
} }
} /* namespace Swagger */
}

View File

@ -64,5 +64,6 @@ signals:
void updateUserSignal(); void updateUserSignal();
}; };
} }
#endif #endif