From 22b14860e6b2bda990a05167ae61d8d7f24a2427 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 21 Jul 2018 22:59:17 +0900 Subject: csapi: add definitions/auth_data.* and optimise out trivial files with the latest GTAD --- .../definitions/location_batch.cpp | 22 ------------ .../definitions/location_batch.h | 30 ---------------- .../definitions/protocol_metadata.cpp | 22 ------------ .../definitions/protocol_metadata.h | 27 -------------- lib/application-service/definitions/user_batch.cpp | 22 ------------ lib/application-service/definitions/user_batch.h | 30 ---------------- lib/csapi/definitions/auth_data.cpp | 29 +++++++++++++++ lib/csapi/definitions/auth_data.h | 33 +++++++++++++++++ lib/csapi/device_management.cpp | 4 +-- lib/csapi/device_management.h | 6 ++-- lib/csapi/gtad.yaml | 2 +- lib/csapi/registration.cpp | 6 ++-- lib/csapi/registration.h | 8 ++--- lib/csapi/third_party_lookup.cpp | 42 +++++++++++----------- lib/csapi/third_party_lookup.h | 25 ++++++------- lib/csapi/{{base}}.cpp.mustache | 9 ++--- lib/csapi/{{base}}.h.mustache | 8 +++-- 17 files changed, 120 insertions(+), 205 deletions(-) delete mode 100644 lib/application-service/definitions/location_batch.cpp delete mode 100644 lib/application-service/definitions/location_batch.h delete mode 100644 lib/application-service/definitions/protocol_metadata.cpp delete mode 100644 lib/application-service/definitions/protocol_metadata.h delete mode 100644 lib/application-service/definitions/user_batch.cpp delete mode 100644 lib/application-service/definitions/user_batch.h create mode 100644 lib/csapi/definitions/auth_data.cpp create mode 100644 lib/csapi/definitions/auth_data.h (limited to 'lib') diff --git a/lib/application-service/definitions/location_batch.cpp b/lib/application-service/definitions/location_batch.cpp deleted file mode 100644 index c9b9e95b..00000000 --- a/lib/application-service/definitions/location_batch.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "location_batch.h" - -using namespace QMatrixClient; - -QJsonObject QMatrixClient::toJson(const LocationBatch& pod) -{ - QJsonObject _json; - return _json; -} - -LocationBatch FromJson::operator()(const QJsonValue& jv) -{ - const auto& _json = jv.toObject(); - LocationBatch result; - - return result; -} - diff --git a/lib/application-service/definitions/location_batch.h b/lib/application-service/definitions/location_batch.h deleted file mode 100644 index cd8c0079..00000000 --- a/lib/application-service/definitions/location_batch.h +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - - -#include "csapi/../application-service/definitions/location.h" -#include "converters.h" -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Data structures - - /// List of matched third party locations. - struct LocationBatch : QVector - { - }; - - QJsonObject toJson(const LocationBatch& pod); - - template <> struct FromJson - { - LocationBatch operator()(const QJsonValue& jv); - }; - -} // namespace QMatrixClient diff --git a/lib/application-service/definitions/protocol_metadata.cpp b/lib/application-service/definitions/protocol_metadata.cpp deleted file mode 100644 index eb740bb6..00000000 --- a/lib/application-service/definitions/protocol_metadata.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "protocol_metadata.h" - -using namespace QMatrixClient; - -QJsonObject QMatrixClient::toJson(const ProtocolMetadata& pod) -{ - QJsonObject _json; - return _json; -} - -ProtocolMetadata FromJson::operator()(const QJsonValue& jv) -{ - const auto& _json = jv.toObject(); - ProtocolMetadata result; - - return result; -} - diff --git a/lib/application-service/definitions/protocol_metadata.h b/lib/application-service/definitions/protocol_metadata.h deleted file mode 100644 index 3c4bcd99..00000000 --- a/lib/application-service/definitions/protocol_metadata.h +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - - - -#include "converters.h" - -namespace QMatrixClient -{ - // Data structures - - /// Dictionary of supported third party protocols. - struct ProtocolMetadata - { - }; - - QJsonObject toJson(const ProtocolMetadata& pod); - - template <> struct FromJson - { - ProtocolMetadata operator()(const QJsonValue& jv); - }; - -} // namespace QMatrixClient diff --git a/lib/application-service/definitions/user_batch.cpp b/lib/application-service/definitions/user_batch.cpp deleted file mode 100644 index bbdf6835..00000000 --- a/lib/application-service/definitions/user_batch.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "user_batch.h" - -using namespace QMatrixClient; - -QJsonObject QMatrixClient::toJson(const UserBatch& pod) -{ - QJsonObject _json; - return _json; -} - -UserBatch FromJson::operator()(const QJsonValue& jv) -{ - const auto& _json = jv.toObject(); - UserBatch result; - - return result; -} - diff --git a/lib/application-service/definitions/user_batch.h b/lib/application-service/definitions/user_batch.h deleted file mode 100644 index 891d3544..00000000 --- a/lib/application-service/definitions/user_batch.h +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - - -#include "csapi/../application-service/definitions/user.h" -#include "converters.h" -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Data structures - - /// List of matched third party users. - struct UserBatch : QVector - { - }; - - QJsonObject toJson(const UserBatch& pod); - - template <> struct FromJson - { - UserBatch operator()(const QJsonValue& jv); - }; - -} // namespace QMatrixClient diff --git a/lib/csapi/definitions/auth_data.cpp b/lib/csapi/definitions/auth_data.cpp new file mode 100644 index 00000000..94e3c05c --- /dev/null +++ b/lib/csapi/definitions/auth_data.cpp @@ -0,0 +1,29 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "auth_data.h" + +using namespace QMatrixClient; + +QJsonObject QMatrixClient::toJson(const AuthenticationData& pod) +{ + QJsonObject _json = toJson(pod.authInfo); + addParam<>(_json, QStringLiteral("type"), pod.type); + addParam(_json, QStringLiteral("session"), pod.session); + return _json; +} + +AuthenticationData FromJson::operator()(const QJsonValue& jv) +{ + auto _json = jv.toObject(); + AuthenticationData result; + result.type = + fromJson(_json.take("type"_ls)); + result.session = + fromJson(_json.take("session"_ls)); + + result.authInfo = fromJson>(_json); + return result; +} + diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h new file mode 100644 index 00000000..0c206e2c --- /dev/null +++ b/lib/csapi/definitions/auth_data.h @@ -0,0 +1,33 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + + + +#include "converters.h" + +namespace QMatrixClient +{ + // Data structures + + /// Used by clients to submit authentication information to the interactive-authentication API + struct AuthenticationData + { + /// The login type that the client is attempting to complete. + QString type; + /// The value of the session key given by the homeserver. + QString session; + /// Keys dependent on the login type + QHash authInfo; + }; + + QJsonObject toJson(const AuthenticationData& pod); + + template <> struct FromJson + { + AuthenticationData operator()(const QJsonValue& jv); + }; + +} // namespace QMatrixClient diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index bbc7e674..4418f6c9 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -98,7 +98,7 @@ UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& display static const auto DeleteDeviceJobName = QStringLiteral("DeleteDeviceJob"); -DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const QJsonObject& auth) +DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const Omittable& auth) : BaseJob(HttpVerb::Delete, DeleteDeviceJobName, basePath % "/devices/" % deviceId) { @@ -109,7 +109,7 @@ DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const QJsonObject& aut static const auto DeleteDevicesJobName = QStringLiteral("DeleteDevicesJob"); -DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const QJsonObject& auth) +DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const Omittable& auth) : BaseJob(HttpVerb::Post, DeleteDevicesJobName, basePath % "/delete_devices") { diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index 978d94d3..338f8529 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -#include +#include "csapi/definitions/auth_data.h" #include #include "converters.h" #include "csapi/definitions/client_device.h" @@ -112,7 +112,7 @@ namespace QMatrixClient * Additional authentication information for the * user-interactive authentication API. */ - explicit DeleteDeviceJob(const QString& deviceId, const QJsonObject& auth = {}); + explicit DeleteDeviceJob(const QString& deviceId, const Omittable& auth = none); }; /// Bulk deletion of devices @@ -130,6 +130,6 @@ namespace QMatrixClient * Additional authentication information for the * user-interactive authentication API. */ - explicit DeleteDevicesJob(const QStringList& devices, const QJsonObject& auth = {}); + explicit DeleteDevicesJob(const QStringList& devices, const Omittable& auth = none); }; } // namespace QMatrixClient diff --git a/lib/csapi/gtad.yaml b/lib/csapi/gtad.yaml index b480e67a..2902c1b3 100644 --- a/lib/csapi/gtad.yaml +++ b/lib/csapi/gtad.yaml @@ -9,6 +9,7 @@ analyzer: origin_server_ts: originServerTimestamp # Instead of originServerTs start: begin # Because start() is a method in BaseJob m.upload.size: uploadSize + AuthenticationData/additionalProperties: authInfo # Structure inside `types`: # - swaggerType: @@ -68,7 +69,6 @@ analyzer: { type: RoomEventPtr, imports: '"events/eventloader.h"' } - /event.yaml$/: { type: EventPtr, imports: '"events/eventloader.h"' } - - /auth_data.yaml$/: *QJsonObject # GTAD 0.6 cannot cope with this one - /m\.room\.member$/: pass # This $ref is only used in an array, see below - //: *UseOmittable # Also apply "avoidCopy" to all other ref'ed types - schema: # Properties of inline structure definitions diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 4991829c..c0a35917 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -30,7 +30,7 @@ BaseJob::Query queryToRegister(const QString& kind) static const auto RegisterJobName = QStringLiteral("RegisterJob"); -RegisterJob::RegisterJob(const QString& kind, const QJsonObject& auth, bool bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName) +RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, bool bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName) : BaseJob(HttpVerb::Post, RegisterJobName, basePath % "/register", queryToRegister(kind), @@ -95,7 +95,7 @@ RequestTokenToRegisterJob::RequestTokenToRegisterJob(const QString& clientSecret static const auto ChangePasswordJobName = QStringLiteral("ChangePasswordJob"); -ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const QJsonObject& auth) +ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const Omittable& auth) : BaseJob(HttpVerb::Post, ChangePasswordJobName, basePath % "/account/password") { @@ -121,7 +121,7 @@ RequestTokenToResetPasswordJob::RequestTokenToResetPasswordJob() static const auto DeactivateAccountJobName = QStringLiteral("DeactivateAccountJob"); -DeactivateAccountJob::DeactivateAccountJob(const QJsonObject& auth) +DeactivateAccountJob::DeactivateAccountJob(const Omittable& auth) : BaseJob(HttpVerb::Post, DeactivateAccountJobName, basePath % "/account/deactivate") { diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 53b2de9d..0709f71b 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -7,7 +7,7 @@ #include "jobs/basejob.h" #include "converters.h" -#include +#include "csapi/definitions/auth_data.h" namespace QMatrixClient { @@ -75,7 +75,7 @@ namespace QMatrixClient * A display name to assign to the newly-created device. Ignored * if ``device_id`` corresponds to a known device. */ - explicit RegisterJob(const QString& kind = QStringLiteral("user"), const QJsonObject& auth = {}, bool bindEmail = false, const QString& username = {}, const QString& password = {}, const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}); + explicit RegisterJob(const QString& kind = QStringLiteral("user"), const Omittable& auth = none, bool bindEmail = false, const QString& username = {}, const QString& password = {}, const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}); ~RegisterJob() override; // Result properties @@ -151,7 +151,7 @@ namespace QMatrixClient * \param auth * Additional authentication information for the user-interactive authentication API. */ - explicit ChangePasswordJob(const QString& newPassword, const QJsonObject& auth = {}); + explicit ChangePasswordJob(const QString& newPassword, const Omittable& auth = none); }; /// Requests a validation token be sent to the given email address for the purpose of resetting a user's password @@ -204,7 +204,7 @@ namespace QMatrixClient * \param auth * Additional authentication information for the user-interactive authentication API. */ - explicit DeactivateAccountJob(const QJsonObject& auth = {}); + explicit DeactivateAccountJob(const Omittable& auth = none); }; /// Checks to see if a username is available on the server. diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index d1158d19..4396738c 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -15,7 +15,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); class GetProtocolsJob::Private { public: - ProtocolMetadata data; + QHash data; }; QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl) @@ -35,7 +35,7 @@ GetProtocolsJob::GetProtocolsJob() GetProtocolsJob::~GetProtocolsJob() = default; -const ProtocolMetadata& GetProtocolsJob::data() const +const QHash& GetProtocolsJob::data() const { return d->data; } @@ -46,7 +46,7 @@ BaseJob::Status GetProtocolsJob::parseJson(const QJsonDocument& data) if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data"_ls)); + d->data = fromJson>(json.value("data"_ls)); return Success; } @@ -91,7 +91,7 @@ BaseJob::Status GetProtocolMetadataJob::parseJson(const QJsonDocument& data) class QueryLocationByProtocolJob::Private { public: - LocationBatch data; + QVector data; }; BaseJob::Query queryToQueryLocationByProtocol(const QString& searchFields) @@ -121,7 +121,7 @@ QueryLocationByProtocolJob::QueryLocationByProtocolJob(const QString& protocol, QueryLocationByProtocolJob::~QueryLocationByProtocolJob() = default; -const LocationBatch& QueryLocationByProtocolJob::data() const +const QVector& QueryLocationByProtocolJob::data() const { return d->data; } @@ -132,36 +132,36 @@ BaseJob::Status QueryLocationByProtocolJob::parseJson(const QJsonDocument& data) if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data"_ls)); + d->data = fromJson>(json.value("data"_ls)); return Success; } class QueryUserByProtocolJob::Private { public: - UserBatch data; + QVector data; }; -BaseJob::Query queryToQueryUserByProtocol(const QString& field1Field2) +BaseJob::Query queryToQueryUserByProtocol(const QString& fields) { BaseJob::Query _q; - addParam(_q, QStringLiteral("field1, field2..."), field1Field2); + addParam(_q, QStringLiteral("fields..."), fields); return _q; } -QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& field1Field2) +QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& fields) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thirdparty/user/" % protocol, - queryToQueryUserByProtocol(field1Field2)); + queryToQueryUserByProtocol(fields)); } static const auto QueryUserByProtocolJobName = QStringLiteral("QueryUserByProtocolJob"); -QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& field1Field2) +QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& fields) : BaseJob(HttpVerb::Get, QueryUserByProtocolJobName, basePath % "/thirdparty/user/" % protocol, - queryToQueryUserByProtocol(field1Field2), + queryToQueryUserByProtocol(fields), {}, false) , d(new Private) { @@ -169,7 +169,7 @@ QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QS QueryUserByProtocolJob::~QueryUserByProtocolJob() = default; -const UserBatch& QueryUserByProtocolJob::data() const +const QVector& QueryUserByProtocolJob::data() const { return d->data; } @@ -180,14 +180,14 @@ BaseJob::Status QueryUserByProtocolJob::parseJson(const QJsonDocument& data) if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data"_ls)); + d->data = fromJson>(json.value("data"_ls)); return Success; } class QueryLocationByAliasJob::Private { public: - LocationBatch data; + QVector data; }; BaseJob::Query queryToQueryLocationByAlias(const QString& alias) @@ -217,7 +217,7 @@ QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) QueryLocationByAliasJob::~QueryLocationByAliasJob() = default; -const LocationBatch& QueryLocationByAliasJob::data() const +const QVector& QueryLocationByAliasJob::data() const { return d->data; } @@ -228,14 +228,14 @@ BaseJob::Status QueryLocationByAliasJob::parseJson(const QJsonDocument& data) if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data"_ls)); + d->data = fromJson>(json.value("data"_ls)); return Success; } class QueryUserByIDJob::Private { public: - UserBatch data; + QVector data; }; BaseJob::Query queryToQueryUserByID(const QString& userid) @@ -265,7 +265,7 @@ QueryUserByIDJob::QueryUserByIDJob(const QString& userid) QueryUserByIDJob::~QueryUserByIDJob() = default; -const UserBatch& QueryUserByIDJob::data() const +const QVector& QueryUserByIDJob::data() const { return d->data; } @@ -276,7 +276,7 @@ BaseJob::Status QueryUserByIDJob::parseJson(const QJsonDocument& data) if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data"_ls)); + d->data = fromJson>(json.value("data"_ls)); return Success; } diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h index 8dec11a4..03d607a8 100644 --- a/lib/csapi/third_party_lookup.h +++ b/lib/csapi/third_party_lookup.h @@ -6,11 +6,12 @@ #include "jobs/basejob.h" -#include "csapi/../application-service/definitions/protocol_metadata.h" -#include "csapi/../application-service/definitions/protocol.h" +#include "csapi/../application-service/definitions/user.h" +#include "csapi/../application-service/definitions/location.h" +#include +#include #include "converters.h" -#include "csapi/../application-service/definitions/location_batch.h" -#include "csapi/../application-service/definitions/user_batch.h" +#include "csapi/../application-service/definitions/protocol.h" namespace QMatrixClient { @@ -39,7 +40,7 @@ namespace QMatrixClient // Result properties /// The protocols supported by the homeserver. - const ProtocolMetadata& data() const; + const QHash& data() const; protected: Status parseJson(const QJsonDocument& data) override; @@ -119,7 +120,7 @@ namespace QMatrixClient // Result properties /// At least one portal room was found. - const LocationBatch& data() const; + const QVector& data() const; protected: Status parseJson(const QJsonDocument& data) override; @@ -139,10 +140,10 @@ namespace QMatrixClient /*! Retrieve the Matrix User ID of a corresponding third party user. * \param protocol * The name of the protocol. - * \param field1Field2 + * \param fields * One or more custom fields that are passed to the AS to help identify the user. */ - explicit QueryUserByProtocolJob(const QString& protocol, const QString& field1Field2 = {}); + explicit QueryUserByProtocolJob(const QString& protocol, const QString& fields = {}); /*! Construct a URL without creating a full-fledged job object * @@ -150,14 +151,14 @@ namespace QMatrixClient * QueryUserByProtocolJob is necessary but the job * itself isn't. */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& field1Field2 = {}); + static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& fields = {}); ~QueryUserByProtocolJob() override; // Result properties /// The Matrix User IDs found with the given parameters. - const UserBatch& data() const; + const QVector& data() const; protected: Status parseJson(const QJsonDocument& data) override; @@ -193,7 +194,7 @@ namespace QMatrixClient // Result properties /// All found third party locations. - const LocationBatch& data() const; + const QVector& data() const; protected: Status parseJson(const QJsonDocument& data) override; @@ -228,7 +229,7 @@ namespace QMatrixClient // Result properties /// An array of third party users. - const UserBatch& data() const; + const QVector& data() const; protected: Status parseJson(const QJsonDocument& data) override; diff --git a/lib/csapi/{{base}}.cpp.mustache b/lib/csapi/{{base}}.cpp.mustache index d25997ed..78265951 100644 --- a/lib/csapi/{{base}}.cpp.mustache +++ b/lib/csapi/{{base}}.cpp.mustache @@ -10,18 +10,19 @@ using namespace QMatrixClient; {{#models.model}}{{#in?}} QJsonObject QMatrixClient::toJson(const {{qualifiedName}}& pod) { - QJsonObject _json;{{#vars}} + QJsonObject _json{{#propertyMap}} = toJson(pod.{{nameCamelCase}}){{/propertyMap}};{{#vars}} addParam<{{^required?}}IfNotEmpty{{/required?}}>(_json, QStringLiteral("{{baseName}}"), pod.{{nameCamelCase}});{{/vars}} return _json; } {{/in?}}{{#out?}} {{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(const QJsonValue& jv) { - const auto& _json = jv.toObject(); + {{^propertyMap}}const auto&{{/propertyMap}}{{#propertyMap}}auto{{/propertyMap}} _json = jv.toObject(); {{qualifiedName}} result; {{#vars}}result.{{nameCamelCase}} = - fromJson<{{dataType.name}}>(_json.value("{{baseName}}"_ls)); - {{/vars}} + fromJson<{{dataType.name}}>(_json.{{#propertyMap}}take{{/propertyMap}}{{^propertyMap}}value{{/propertyMap}}("{{baseName}}"_ls)); + {{/vars}}{{#propertyMap}} + result.{{nameCamelCase}} = fromJson<{{dataType.name}}>(_json);{{/propertyMap}} return result; } {{/out?}}{{/models.model}}{{#operations}} diff --git a/lib/csapi/{{base}}.h.mustache b/lib/csapi/{{base}}.h.mustache index 1e7c0132..7e2ca9d4 100644 --- a/lib/csapi/{{base}}.h.mustache +++ b/lib/csapi/{{base}}.h.mustache @@ -16,7 +16,9 @@ namespace QMatrixClient { {{#vars}}{{#description}} /// {{_}} {{/description}} {{>maybeOmittableType}} {{nameCamelCase}}; -{{/vars}} }; +{{/vars}}{{#propertyMap}}{{#description}} /// {{_}} +{{/description}} {{>maybeOmittableType}} {{nameCamelCase}}; +{{/propertyMap}} }; {{#in?}} QJsonObject toJson(const {{name}}& pod); {{/in?}}{{#out?}} @@ -40,7 +42,9 @@ namespace QMatrixClient { {{#vars}}{{#description}} /// {{_}} {{/description}} {{>maybeOmittableType}} {{nameCamelCase}}; -{{/vars}} }; +{{/vars}}{{#propertyMap}}{{#description}} /// {{_}} +{{/description}} {{>maybeOmittableType}} {{nameCamelCase}}; +{{/propertyMap}} }; {{/ model}} // Construction/destruction {{/ models}}{{#allParams?}} -- cgit v1.2.3