Skip to content

Commit

Permalink
fix(dynamite): do not add someOf.data to the interface
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolas Rimikis <[email protected]>
  • Loading branch information
Leptopoda committed Oct 22, 2023
1 parent fe29bb8 commit 399d5d5
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 87 deletions.
45 changes: 22 additions & 23 deletions packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions packages/dynamite/dynamite/lib/src/helpers/built_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const interfaceSuffix = 'Interface';
Spec buildBuiltClass(
final String className, {
final Iterable<String>? defaults,
final Iterable<Method>? methods,
final bool customSerializer = false,
}) =>
Class(
Expand All @@ -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(
Expand Down
15 changes: 10 additions & 5 deletions packages/nextcloud/lib/src/api/core.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -4750,6 +4749,8 @@ abstract class AutocompleteResult_Status

@BuiltValueSerializer(custom: true)
static Serializer<AutocompleteResult_Status> get serializer => _$AutocompleteResult_StatusSerializer();

JsonObject get data;
}

class _$AutocompleteResult_StatusSerializer implements PrimitiveSerializer<AutocompleteResult_Status> {
Expand Down Expand Up @@ -5753,7 +5754,6 @@ abstract class HoverCardGetUserResponseApplicationJson

@BuiltValue(instantiable: false)
abstract interface class NavigationEntry_OrderInterface {
JsonObject get data;
int? get $int;
String? get string;
}
Expand All @@ -5777,6 +5777,8 @@ abstract class NavigationEntry_Order

@BuiltValueSerializer(custom: true)
static Serializer<NavigationEntry_Order> get serializer => _$NavigationEntry_OrderSerializer();

JsonObject get data;
}

class _$NavigationEntry_OrderSerializer implements PrimitiveSerializer<NavigationEntry_Order> {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -7569,6 +7570,8 @@ abstract class OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_Capabilities
@BuiltValueSerializer(custom: true)
static Serializer<OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_Capabilities> get serializer =>
_$OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesSerializer();

JsonObject get data;
}

class _$OcsGetCapabilitiesResponseApplicationJson_Ocs_Data_CapabilitiesSerializer
Expand Down Expand Up @@ -9198,7 +9201,6 @@ abstract class UnifiedSearchGetProvidersResponseApplicationJson

@BuiltValue(instantiable: false)
abstract interface class UnifiedSearchSearchCursorInterface {
JsonObject get data;
int? get $int;
String? get string;
}
Expand All @@ -9223,6 +9225,8 @@ abstract class UnifiedSearchSearchCursor

@BuiltValueSerializer(custom: true)
static Serializer<UnifiedSearchSearchCursor> get serializer => _$UnifiedSearchSearchCursorSerializer();

JsonObject get data;
}

class _$UnifiedSearchSearchCursorSerializer implements PrimitiveSerializer<UnifiedSearchSearchCursor> {
Expand Down Expand Up @@ -9292,7 +9296,6 @@ abstract class UnifiedSearchResultEntry

@BuiltValue(instantiable: false)
abstract interface class UnifiedSearchResult_CursorInterface {
JsonObject get data;
int? get $int;
String? get string;
}
Expand All @@ -9319,6 +9322,8 @@ abstract class UnifiedSearchResult_Cursor

@BuiltValueSerializer(custom: true)
static Serializer<UnifiedSearchResult_Cursor> get serializer => _$UnifiedSearchResult_CursorSerializer();

JsonObject get data;
}

class _$UnifiedSearchResult_CursorSerializer implements PrimitiveSerializer<UnifiedSearchResult_Cursor> {
Expand Down
15 changes: 0 additions & 15 deletions packages/nextcloud/lib/src/api/core.openapi.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions packages/nextcloud/lib/src/api/files_sharing.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2873,7 +2873,6 @@ abstract class RemoteUnshareResponseApplicationJson

@BuiltValue(instantiable: false)
abstract interface class ShareInfo_SizeInterface {
JsonObject get data;
int? get $int;
num? get $num;
}
Expand All @@ -2896,6 +2895,8 @@ abstract class ShareInfo_Size implements ShareInfo_SizeInterface, Built<ShareInf

@BuiltValueSerializer(custom: true)
static Serializer<ShareInfo_Size> get serializer => _$ShareInfo_SizeSerializer();

JsonObject get data;
}

class _$ShareInfo_SizeSerializer implements PrimitiveSerializer<ShareInfo_Size> {
Expand Down Expand Up @@ -2965,7 +2966,6 @@ abstract class ShareInfo implements ShareInfoInterface, Built<ShareInfo, ShareIn

@BuiltValue(instantiable: false)
abstract interface class Share_ItemSizeInterface {
JsonObject get data;
num? get $num;
int? get $int;
}
Expand All @@ -2988,6 +2988,8 @@ abstract class Share_ItemSize implements Share_ItemSizeInterface, Built<Share_It

@BuiltValueSerializer(custom: true)
static Serializer<Share_ItemSize> get serializer => _$Share_ItemSizeSerializer();

JsonObject get data;
}

class _$Share_ItemSizeSerializer implements PrimitiveSerializer<Share_ItemSize> {
Expand Down Expand Up @@ -3647,7 +3649,6 @@ abstract class ShareapiAcceptShareResponseApplicationJson

@BuiltValue(instantiable: false)
abstract interface class ShareesapiSearchShareTypeInterface {
JsonObject get data;
int? get $int;
BuiltList<int>? get builtListInt;
}
Expand All @@ -3672,6 +3673,8 @@ abstract class ShareesapiSearchShareType

@BuiltValueSerializer(custom: true)
static Serializer<ShareesapiSearchShareType> get serializer => _$ShareesapiSearchShareTypeSerializer();

JsonObject get data;
}

class _$ShareesapiSearchShareTypeSerializer implements PrimitiveSerializer<ShareesapiSearchShareType> {
Expand Down Expand Up @@ -4340,7 +4343,6 @@ abstract class ShareesapiSearchResponseApplicationJson

@BuiltValue(instantiable: false)
abstract interface class ShareesapiFindRecommendedShareTypeInterface {
JsonObject get data;
int? get $int;
BuiltList<int>? get builtListInt;
}
Expand Down Expand Up @@ -4368,6 +4370,8 @@ abstract class ShareesapiFindRecommendedShareType
@BuiltValueSerializer(custom: true)
static Serializer<ShareesapiFindRecommendedShareType> get serializer =>
_$ShareesapiFindRecommendedShareTypeSerializer();

JsonObject get data;
}

class _$ShareesapiFindRecommendedShareTypeSerializer
Expand Down
12 changes: 0 additions & 12 deletions packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 399d5d5

Please sign in to comment.