From af63766d6faaa131c1b4be40dbd61410eaa55ce4 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 30 Nov 2022 13:33:52 +0100 Subject: [PATCH] dynamite,nextcloud: Add missing fromJsonString and toJsonString for oneOf, anyOf and allOf --- .../dynamite/lib/src/openapi_builder.dart | 35 ++++++++++++++- .../nextcloud/lib/src/nextcloud.openapi.dart | 43 +++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index a6088b06..60674678 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -1299,8 +1299,24 @@ TypeResult resolveType( ); }, ), + Constructor( + (final b) { + b + ..factory = true + ..lambda = true + ..name = 'fromJsonString' + ..requiredParameters.add( + Parameter( + (final b) => b + ..name = 'data' + ..type = refer('String'), + ), + ) + ..body = Code('$identifier.fromJson(json.decode(data))'); + }, + ), ]) - ..methods.add( + ..methods.addAll([ Method( (final b) => b ..name = 'toJson' @@ -1308,7 +1324,22 @@ TypeResult resolveType( ..lambda = true ..body = const Code('_data'), ), - ); + Method( + (final b) => b + ..name = 'toJsonString' + ..returns = refer('String') + ..lambda = true + ..static = true + ..requiredParameters.add( + Parameter( + (final b) => b + ..name = 'data' + ..type = refer('dynamic'), + ), + ) + ..body = const Code('json.encode(data)'), + ), + ]); }, ), ); diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.dart b/packages/nextcloud/lib/src/nextcloud.openapi.dart index 44a267c5..8ebf5bfc 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.dart @@ -2829,6 +2829,9 @@ class CoreNavigationApps_Ocs_Data_Order { ); } + factory CoreNavigationApps_Ocs_Data_Order.fromJsonString(String data) => + CoreNavigationApps_Ocs_Data_Order.fromJson(json.decode(data)); + final dynamic _data; final int? $int; @@ -2838,6 +2841,8 @@ class CoreNavigationApps_Ocs_Data_Order { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } @JsonSerializable() @@ -3348,6 +3353,9 @@ class NotificationsNotification_SubjectRichParameters { ); } + factory NotificationsNotification_SubjectRichParameters.fromJsonString(String data) => + NotificationsNotification_SubjectRichParameters.fromJson(json.decode(data)); + final dynamic _data; final Map? mapStringDynamic; @@ -3355,6 +3363,8 @@ class NotificationsNotification_SubjectRichParameters { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } class NotificationsNotification_MessageRichParameters { @@ -3374,6 +3384,9 @@ class NotificationsNotification_MessageRichParameters { ); } + factory NotificationsNotification_MessageRichParameters.fromJsonString(String data) => + NotificationsNotification_MessageRichParameters.fromJson(json.decode(data)); + final dynamic _data; final Map? mapStringDynamic; @@ -3381,6 +3394,8 @@ class NotificationsNotification_MessageRichParameters { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } @JsonSerializable() @@ -3976,6 +3991,8 @@ class UserStatusClearAt_Time { ); } + factory UserStatusClearAt_Time.fromJsonString(String data) => UserStatusClearAt_Time.fromJson(json.decode(data)); + final dynamic _data; final UserStatusClearAt_Time0? userStatusClearAtTime0; @@ -3986,6 +4003,8 @@ class UserStatusClearAt_Time { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } @JsonSerializable() @@ -4034,6 +4053,9 @@ class UserStatusPublicUserStatus_ClearAt { ); } + factory UserStatusPublicUserStatus_ClearAt.fromJsonString(String data) => + UserStatusPublicUserStatus_ClearAt.fromJson(json.decode(data)); + final dynamic _data; final UserStatusClearAt? userStatusClearAt; @@ -4044,6 +4066,8 @@ class UserStatusPublicUserStatus_ClearAt { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } enum UserStatusType { @@ -4166,6 +4190,9 @@ class UserStatusFindStatus_Ocs_Data { ); } + factory UserStatusFindStatus_Ocs_Data.fromJsonString(String data) => + UserStatusFindStatus_Ocs_Data.fromJson(json.decode(data)); + final dynamic _data; final UserStatusPublicUserStatus? userStatusPublicUserStatus; @@ -4173,6 +4200,8 @@ class UserStatusFindStatus_Ocs_Data { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } @JsonSerializable() @@ -4239,6 +4268,8 @@ class UserStatus_ClearAt { ); } + factory UserStatus_ClearAt.fromJsonString(String data) => UserStatus_ClearAt.fromJson(json.decode(data)); + final dynamic _data; final UserStatusClearAt? userStatusClearAt; @@ -4249,6 +4280,8 @@ class UserStatus_ClearAt { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } @JsonSerializable() @@ -4308,6 +4341,9 @@ class UserStatusGetUserStatus_Ocs_Data { ); } + factory UserStatusGetUserStatus_Ocs_Data.fromJsonString(String data) => + UserStatusGetUserStatus_Ocs_Data.fromJson(json.decode(data)); + final dynamic _data; final UserStatus? userStatus; @@ -4315,6 +4351,8 @@ class UserStatusGetUserStatus_Ocs_Data { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } @JsonSerializable() @@ -4382,6 +4420,9 @@ class UserStatusPredefinedStatus_ClearAt { ); } + factory UserStatusPredefinedStatus_ClearAt.fromJsonString(String data) => + UserStatusPredefinedStatus_ClearAt.fromJson(json.decode(data)); + final dynamic _data; final UserStatusClearAt? userStatusClearAt; @@ -4392,6 +4433,8 @@ class UserStatusPredefinedStatus_ClearAt { // coverage:ignore-start dynamic toJson() => _data; // coverage:ignore-end + + static String toJsonString(dynamic data) => json.encode(data); } @JsonSerializable()