From 399d5d532ef947a40174c9263a9fd5e74e1a3939 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 22 Oct 2023 17:37:08 +0200 Subject: [PATCH] fix(dynamite): do not add someOf.data to the interface Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/ofs_builder.dart | 45 +++++++++---------- .../dynamite/lib/src/helpers/built_value.dart | 5 +++ .../nextcloud/lib/src/api/core.openapi.dart | 15 ++++--- .../nextcloud/lib/src/api/core.openapi.g.dart | 15 ------- .../lib/src/api/files_sharing.openapi.dart | 12 +++-- .../lib/src/api/files_sharing.openapi.g.dart | 12 ----- .../lib/src/api/provisioning_api.openapi.dart | 15 ++++--- .../src/api/provisioning_api.openapi.g.dart | 15 ------- .../lib/src/api/user_status.openapi.dart | 6 ++- .../lib/src/api/user_status.openapi.g.dart | 6 --- 10 files changed, 59 insertions(+), 87 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart b/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart index 8cc41f33..4a156083 100644 --- a/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart +++ b/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart @@ -104,37 +104,36 @@ TypeResult resolveOfs( state.output.addAll([ buildInterface( identifier, - methods: BuiltList.build((final b) { - b.add( - Method( + methods: BuiltList.from( + results.map( + (final result) => Method( (final b) { + final s = schema.ofs![results.indexOf(result)]; b - ..name = 'data' - ..returns = refer('JsonObject') - ..type = MethodType.getter; + ..name = fields[result.name] + ..returns = refer(result.nullableName) + ..type = MethodType.getter + ..docs.addAll(s.formattedDescription); }, ), - ); - - for (final result in results) { - b.add( - Method( - (final b) { - final s = schema.ofs![results.indexOf(result)]; - b - ..name = fields[result.name] - ..returns = refer(result.nullableName) - ..type = MethodType.getter - ..docs.addAll(s.formattedDescription); - }, - ), - ); - } - }), + ), + ), ), buildBuiltClass( identifier, customSerializer: true, + methods: BuiltList.build( + (final b) => b.add( + Method( + (final b) { + b + ..name = 'data' + ..returns = refer('JsonObject') + ..type = MethodType.getter; + }, + ), + ), + ), ), Class( (final b) => b diff --git a/packages/dynamite/dynamite/lib/src/helpers/built_value.dart b/packages/dynamite/dynamite/lib/src/helpers/built_value.dart index e8c80836..6360bf2a 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/built_value.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/built_value.dart @@ -9,6 +9,7 @@ const interfaceSuffix = 'Interface'; Spec buildBuiltClass( final String className, { final Iterable? defaults, + final Iterable? methods, final bool customSerializer = false, }) => Class( @@ -32,6 +33,10 @@ Spec buildBuiltClass( buildSerializer(className, isCustom: customSerializer), ]); + if (methods != null) { + b.methods.addAll(methods); + } + if (defaults != null && defaults.isNotEmpty) { b.methods.add( Method( diff --git a/packages/nextcloud/lib/src/api/core.openapi.dart b/packages/nextcloud/lib/src/api/core.openapi.dart index 9d5efec6..fac9f2e1 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.dart @@ -4725,7 +4725,6 @@ abstract class AutocompleteResult_Status0 @BuiltValue(instantiable: false) abstract interface class AutocompleteResult_StatusInterface { - JsonObject get data; AutocompleteResult_Status0? get autocompleteResultStatus0; String? get string; } @@ -4750,6 +4749,8 @@ abstract class AutocompleteResult_Status @BuiltValueSerializer(custom: true) static Serializer get serializer => _$AutocompleteResult_StatusSerializer(); + + JsonObject get data; } class _$AutocompleteResult_StatusSerializer implements PrimitiveSerializer { @@ -5753,7 +5754,6 @@ abstract class HoverCardGetUserResponseApplicationJson @BuiltValue(instantiable: false) abstract interface class NavigationEntry_OrderInterface { - JsonObject get data; int? get $int; String? get string; } @@ -5777,6 +5777,8 @@ abstract class NavigationEntry_Order @BuiltValueSerializer(custom: true) static Serializer get serializer => _$NavigationEntry_OrderSerializer(); + + JsonObject get data; } class _$NavigationEntry_OrderSerializer implements PrimitiveSerializer { @@ -7528,7 +7530,6 @@ abstract class WeatherStatusCapabilities @BuiltValue(instantiable: false) abstract interface class OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesInterface { - JsonObject get data; CommentsCapabilities? get commentsCapabilities; DavCapabilities? get davCapabilities; FilesCapabilities? get filesCapabilities; @@ -7569,6 +7570,8 @@ abstract class OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_Capabilities @BuiltValueSerializer(custom: true) static Serializer get serializer => _$OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesSerializer(); + + JsonObject get data; } class _$OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesSerializer @@ -9198,7 +9201,6 @@ abstract class UnifiedSearchGetProvidersResponseApplicationJson @BuiltValue(instantiable: false) abstract interface class UnifiedSearchSearchCursorInterface { - JsonObject get data; int? get $int; String? get string; } @@ -9223,6 +9225,8 @@ abstract class UnifiedSearchSearchCursor @BuiltValueSerializer(custom: true) static Serializer get serializer => _$UnifiedSearchSearchCursorSerializer(); + + JsonObject get data; } class _$UnifiedSearchSearchCursorSerializer implements PrimitiveSerializer { @@ -9292,7 +9296,6 @@ abstract class UnifiedSearchResultEntry @BuiltValue(instantiable: false) abstract interface class UnifiedSearchResult_CursorInterface { - JsonObject get data; int? get $int; String? get string; } @@ -9319,6 +9322,8 @@ abstract class UnifiedSearchResult_Cursor @BuiltValueSerializer(custom: true) static Serializer get serializer => _$UnifiedSearchResult_CursorSerializer(); + + JsonObject get data; } class _$UnifiedSearchResult_CursorSerializer implements PrimitiveSerializer { diff --git a/packages/nextcloud/lib/src/api/core.openapi.g.dart b/packages/nextcloud/lib/src/api/core.openapi.g.dart index ddf970e3..8a852cb0 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.g.dart @@ -9288,9 +9288,6 @@ class AutocompleteResult_Status0Builder abstract mixin class AutocompleteResult_StatusInterfaceBuilder { void replace(AutocompleteResult_StatusInterface other); void update(void Function(AutocompleteResult_StatusInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - AutocompleteResult_Status0Builder get autocompleteResultStatus0; set autocompleteResultStatus0(AutocompleteResult_Status0Builder? autocompleteResultStatus0); @@ -12948,9 +12945,6 @@ class HoverCardGetUserResponseApplicationJsonBuilder abstract mixin class NavigationEntry_OrderInterfaceBuilder { void replace(NavigationEntry_OrderInterface other); void update(void Function(NavigationEntry_OrderInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - int? get $int; set $int(int? $int); @@ -19888,9 +19882,6 @@ class WeatherStatusCapabilitiesBuilder abstract mixin class OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesInterfaceBuilder { void replace(OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesInterface other); void update(void Function(OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - CommentsCapabilitiesBuilder get commentsCapabilities; set commentsCapabilities(CommentsCapabilitiesBuilder? commentsCapabilities); @@ -25909,9 +25900,6 @@ class UnifiedSearchGetProvidersResponseApplicationJsonBuilder abstract mixin class UnifiedSearchSearchCursorInterfaceBuilder { void replace(UnifiedSearchSearchCursorInterface other); void update(void Function(UnifiedSearchSearchCursorInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - int? get $int; set $int(int? $int); @@ -26230,9 +26218,6 @@ class UnifiedSearchResultEntryBuilder abstract mixin class UnifiedSearchResult_CursorInterfaceBuilder { void replace(UnifiedSearchResult_CursorInterface other); void update(void Function(UnifiedSearchResult_CursorInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - int? get $int; set $int(int? $int); diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart index 3e692b84..e59c267d 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart @@ -2873,7 +2873,6 @@ abstract class RemoteUnshareResponseApplicationJson @BuiltValue(instantiable: false) abstract interface class ShareInfo_SizeInterface { - JsonObject get data; int? get $int; num? get $num; } @@ -2896,6 +2895,8 @@ abstract class ShareInfo_Size implements ShareInfo_SizeInterface, Built get serializer => _$ShareInfo_SizeSerializer(); + + JsonObject get data; } class _$ShareInfo_SizeSerializer implements PrimitiveSerializer { @@ -2965,7 +2966,6 @@ abstract class ShareInfo implements ShareInfoInterface, Built get serializer => _$Share_ItemSizeSerializer(); + + JsonObject get data; } class _$Share_ItemSizeSerializer implements PrimitiveSerializer { @@ -3647,7 +3649,6 @@ abstract class ShareapiAcceptShareResponseApplicationJson @BuiltValue(instantiable: false) abstract interface class ShareesapiSearchShareTypeInterface { - JsonObject get data; int? get $int; BuiltList? get builtListInt; } @@ -3672,6 +3673,8 @@ abstract class ShareesapiSearchShareType @BuiltValueSerializer(custom: true) static Serializer get serializer => _$ShareesapiSearchShareTypeSerializer(); + + JsonObject get data; } class _$ShareesapiSearchShareTypeSerializer implements PrimitiveSerializer { @@ -4340,7 +4343,6 @@ abstract class ShareesapiSearchResponseApplicationJson @BuiltValue(instantiable: false) abstract interface class ShareesapiFindRecommendedShareTypeInterface { - JsonObject get data; int? get $int; BuiltList? get builtListInt; } @@ -4368,6 +4370,8 @@ abstract class ShareesapiFindRecommendedShareType @BuiltValueSerializer(custom: true) static Serializer get serializer => _$ShareesapiFindRecommendedShareTypeSerializer(); + + JsonObject get data; } class _$ShareesapiFindRecommendedShareTypeSerializer diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart index e354fbb5..68d7b53d 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart @@ -7356,9 +7356,6 @@ class RemoteUnshareResponseApplicationJsonBuilder abstract mixin class ShareInfo_SizeInterfaceBuilder { void replace(ShareInfo_SizeInterface other); void update(void Function(ShareInfo_SizeInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - int? get $int; set $int(int? $int); @@ -7715,9 +7712,6 @@ class ShareInfoBuilder implements Builder, ShareInf abstract mixin class Share_ItemSizeInterfaceBuilder { void replace(Share_ItemSizeInterface other); void update(void Function(Share_ItemSizeInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - num? get $num; set $num(num? $num); @@ -10475,9 +10469,6 @@ class ShareapiAcceptShareResponseApplicationJsonBuilder abstract mixin class ShareesapiSearchShareTypeInterfaceBuilder { void replace(ShareesapiSearchShareTypeInterface other); void update(void Function(ShareesapiSearchShareTypeInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - int? get $int; set $int(int? $int); @@ -13717,9 +13708,6 @@ class ShareesapiSearchResponseApplicationJsonBuilder abstract mixin class ShareesapiFindRecommendedShareTypeInterfaceBuilder { void replace(ShareesapiFindRecommendedShareTypeInterface other); void update(void Function(ShareesapiFindRecommendedShareTypeInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - int? get $int; set $int(int? $int); diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index 32bfc2d1..b48db58e 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -5172,7 +5172,6 @@ abstract class GroupsAddGroupResponseApplicationJson @BuiltValue(instantiable: false) abstract interface class GroupDetails_UsercountInterface { - JsonObject get data; bool? get $bool; int? get $int; } @@ -5196,6 +5195,8 @@ abstract class GroupDetails_Usercount @BuiltValueSerializer(custom: true) static Serializer get serializer => _$GroupDetails_UsercountSerializer(); + + JsonObject get data; } class _$GroupDetails_UsercountSerializer implements PrimitiveSerializer { @@ -5233,7 +5234,6 @@ class _$GroupDetails_UsercountSerializer implements PrimitiveSerializer get serializer => _$GroupDetails_DisabledSerializer(); + + JsonObject get data; } class _$GroupDetails_DisabledSerializer implements PrimitiveSerializer { @@ -5536,7 +5538,6 @@ abstract class UserDetails_BackendCapabilities @BuiltValue(instantiable: false) abstract interface class UserDetailsQuota_QuotaInterface { - JsonObject get data; num? get $num; int? get $int; String? get string; @@ -5561,6 +5562,8 @@ abstract class UserDetailsQuota_Quota @BuiltValueSerializer(custom: true) static Serializer get serializer => _$UserDetailsQuota_QuotaSerializer(); + + JsonObject get data; } class _$UserDetailsQuota_QuotaSerializer implements PrimitiveSerializer { @@ -5732,7 +5735,6 @@ abstract class GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users1 @BuiltValue(instantiable: false) abstract interface class GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterface { - JsonObject get data; UserDetails? get userDetails; GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users1? get groupsGetGroupUsersDetailsResponseApplicationJsonOcsDataUsers1; @@ -5763,6 +5765,8 @@ abstract class GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users @BuiltValueSerializer(custom: true) static Serializer get serializer => _$GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_UsersSerializer(); + + JsonObject get data; } class _$GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_UsersSerializer @@ -6646,7 +6650,6 @@ abstract class UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_Users1 @BuiltValue(instantiable: false) abstract interface class UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterface { - JsonObject get data; UserDetails? get userDetails; UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_Users1? get usersGetUsersDetailsResponseApplicationJsonOcsDataUsers1; @@ -6677,6 +6680,8 @@ abstract class UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_Users @BuiltValueSerializer(custom: true) static Serializer get serializer => _$UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_UsersSerializer(); + + JsonObject get data; } class _$UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_UsersSerializer diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart index a951d4c2..6c3478b5 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart @@ -9640,9 +9640,6 @@ class GroupsAddGroupResponseApplicationJsonBuilder abstract mixin class GroupDetails_UsercountInterfaceBuilder { void replace(GroupDetails_UsercountInterface other); void update(void Function(GroupDetails_UsercountInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - bool? get $bool; set $bool(bool? $bool); @@ -9755,9 +9752,6 @@ class GroupDetails_UsercountBuilder abstract mixin class GroupDetails_DisabledInterfaceBuilder { void replace(GroupDetails_DisabledInterface other); void update(void Function(GroupDetails_DisabledInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - bool? get $bool; set $bool(bool? $bool); @@ -10825,9 +10819,6 @@ class UserDetails_BackendCapabilitiesBuilder abstract mixin class UserDetailsQuota_QuotaInterfaceBuilder { void replace(UserDetailsQuota_QuotaInterface other); void update(void Function(UserDetailsQuota_QuotaInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - num? get $num; set $num(num? $num); @@ -11946,9 +11937,6 @@ class GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users1Builder abstract mixin class GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterfaceBuilder { void replace(GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterface other); void update(void Function(GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - UserDetailsBuilder get userDetails; set userDetails(UserDetailsBuilder? userDetails); @@ -15114,9 +15102,6 @@ class UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_Users1Builder abstract mixin class UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterfaceBuilder { void replace(UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterface other); void update(void Function(UsersGetUsersDetailsResponseApplicationJson_Ocs_Data_UsersInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - UserDetailsBuilder get userDetails; set userDetails(UserDetailsBuilder? userDetails); diff --git a/packages/nextcloud/lib/src/api/user_status.openapi.dart b/packages/nextcloud/lib/src/api/user_status.openapi.dart index 345b4184..82f8658a 100644 --- a/packages/nextcloud/lib/src/api/user_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/user_status.openapi.dart @@ -1161,7 +1161,6 @@ class ClearAtTimeType extends EnumClass { @BuiltValue(instantiable: false) abstract interface class ClearAt_TimeInterface { - JsonObject get data; int? get $int; ClearAtTimeType? get clearAtTimeType; } @@ -1183,6 +1182,8 @@ abstract class ClearAt_Time implements ClearAt_TimeInterface, Built get serializer => _$ClearAt_TimeSerializer(); + + JsonObject get data; } class _$ClearAt_TimeSerializer implements PrimitiveSerializer { @@ -1768,7 +1769,6 @@ abstract class UserStatusClearMessageResponseApplicationJson @BuiltValue(instantiable: false) abstract interface class UserStatusRevertStatusResponseApplicationJson_Ocs_DataInterface { - JsonObject get data; Private? get private; JsonObject? get jsonObject; } @@ -1798,6 +1798,8 @@ abstract class UserStatusRevertStatusResponseApplicationJson_Ocs_Data @BuiltValueSerializer(custom: true) static Serializer get serializer => _$UserStatusRevertStatusResponseApplicationJson_Ocs_DataSerializer(); + + JsonObject get data; } class _$UserStatusRevertStatusResponseApplicationJson_Ocs_DataSerializer diff --git a/packages/nextcloud/lib/src/api/user_status.openapi.g.dart b/packages/nextcloud/lib/src/api/user_status.openapi.g.dart index 0c2cbebd..90e616a1 100644 --- a/packages/nextcloud/lib/src/api/user_status.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/user_status.openapi.g.dart @@ -2208,9 +2208,6 @@ class HeartbeatHeartbeatResponseApplicationJsonBuilder abstract mixin class ClearAt_TimeInterfaceBuilder { void replace(ClearAt_TimeInterface other); void update(void Function(ClearAt_TimeInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - int? get $int; set $int(int? $int); @@ -4391,9 +4388,6 @@ class UserStatusClearMessageResponseApplicationJsonBuilder abstract mixin class UserStatusRevertStatusResponseApplicationJson_Ocs_DataInterfaceBuilder { void replace(UserStatusRevertStatusResponseApplicationJson_Ocs_DataInterface other); void update(void Function(UserStatusRevertStatusResponseApplicationJson_Ocs_DataInterfaceBuilder) updates); - JsonObject? get data; - set data(JsonObject? data); - PrivateBuilder get private; set private(PrivateBuilder? private);