Skip to content

Commit 6660b74

Browse files
authored
Add Q_DECLARE_METATYPE to the generated models and remove ref in signals (#3091)
1 parent 19f47d0 commit 6660b74

File tree

27 files changed

+95
-43
lines changed

27 files changed

+95
-43
lines changed

modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ signals:
3838
{{/operation}}{{/operations}}
3939
{{#operations}}{{#operation}}void {{nickname}}SignalFull({{prefix}}HttpRequestWorker* worker{{#returnType}}, {{{returnType}}} summary{{/returnType}});
4040
{{/operation}}{{/operations}}
41-
{{#operations}}{{#operation}}void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString& error_str);
41+
{{#operations}}{{#operation}}void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString error_str);
4242
{{/operation}}{{/operations}}
43-
{{#operations}}{{#operation}}void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
43+
{{#operations}}{{#operation}}void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
4444
{{/operation}}{{/operations}}
4545
};
4646

modules/openapi-generator/src/main/resources/cpp-qt5-client/enum.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <QString>
66
#include <QJsonValue>
7+
#include <QMetaType>
78

89
{{#cppNamespaceDeclarations}}
910
namespace {{this}} {
@@ -54,4 +55,6 @@ private :
5455
}
5556
{{/cppNamespaceDeclarations}}
5657

58+
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}Enum)
59+
5760
#endif // {{prefix}}_ENUM_H

modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ private:
7474
}
7575
{{/cppNamespaceDeclarations}}
7676

77+
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{classname}})
78+
7779
#endif // {{classname}}_H
7880
{{/model}}
7981
{{/models}}

modules/openapi-generator/src/main/resources/cpp-qt5-client/object.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <QJsonObject>
66
#include <QJsonDocument>
7+
#include <QMetaType>
78

89
{{#cppNamespaceDeclarations}}
910
namespace {{this}} {
@@ -56,4 +57,6 @@ private :
5657
}
5758
{{/cppNamespaceDeclarations}}
5859

60+
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}Object)
61+
5962
#endif // {{prefix}}_OBJECT_H

modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/enum.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <QString>
66
#include <QJsonValue>
7+
#include <QMetaType>
78

89
{{#cppNamespaceDeclarations}}
910
namespace {{this}} {
@@ -54,4 +55,6 @@ private :
5455
}
5556
{{/cppNamespaceDeclarations}}
5657

58+
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}Enum)
59+
5760
#endif // {{prefix}}_ENUM_H

modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-header.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ private:
7474
}
7575
{{/cppNamespaceDeclarations}}
7676

77+
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{classname}})
78+
7779
#endif // {{classname}}_H
7880
{{/model}}
7981
{{/models}}

modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/object.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <QJsonObject>
66
#include <QJsonDocument>
7+
#include <QMetaType>
78

89
{{#cppNamespaceDeclarations}}
910
namespace {{this}} {
@@ -56,4 +57,6 @@ private :
5657
}
5758
{{/cppNamespaceDeclarations}}
5859

60+
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}Object)
61+
5962
#endif // {{prefix}}_OBJECT_H
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.1-SNAPSHOT
1+
4.0.2-SNAPSHOT

samples/client/petstore/cpp-qt5/client/OAIApiResponse.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,6 @@ class OAIApiResponse: public OAIObject {
7676

7777
}
7878

79+
Q_DECLARE_METATYPE(OpenAPI::OAIApiResponse)
80+
7981
#endif // OAIApiResponse_H

samples/client/petstore/cpp-qt5/client/OAICategory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ class OAICategory: public OAIObject {
6868

6969
}
7070

71+
Q_DECLARE_METATYPE(OpenAPI::OAICategory)
72+
7173
#endif // OAICategory_H

0 commit comments

Comments
 (0)