From 346ffbc4caa4a17c5ebfb26aa6d65b08592f1815 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 2 Apr 2023 17:42:10 +0200 Subject: [PATCH] Relax oneOf assertion --- packages/dynamite/lib/src/openapi_builder.dart | 5 ++++- .../nextcloud/lib/src/nextcloud.openapi.dart | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index c598d8e1..33939b6b 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -1549,7 +1549,10 @@ TypeResult resolveType( ], ], if (schema.oneOf != null) ...[ - "assert([${fields.values.join(',')}].where((final x) => x != null).length == 1, 'Need oneOf for \$data');", + "assert([${fields.values.join(',')}].where((final x) => x != null).length >= 1, 'Need oneOf for \$data');", + ], + if (schema.anyOf != null) ...[ + "assert([${fields.values.join(',')}].where((final x) => x != null).length >= 1, 'Need anyOf for \$data');", ], 'return ${state.prefix}$identifier(', 'data,', diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.dart b/packages/nextcloud/lib/src/nextcloud.openapi.dart index 183dc0d3..1025253a 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.dart @@ -3495,7 +3495,7 @@ class NextcloudCoreNavigationApps_Ocs_Data_Order { try { string = (data as String); } catch (_) {} - assert([$int, string].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([$int, string].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudCoreNavigationApps_Ocs_Data_Order( data, $int: $int, @@ -3722,7 +3722,7 @@ class NextcloudCoreAutocompleteResult_Ocs_Data_Status { try { string = (data as String); } catch (_) {} - assert([listDynamic, string].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([listDynamic, string].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudCoreAutocompleteResult_Ocs_Data_Status( data, listDynamic: listDynamic, @@ -5201,7 +5201,7 @@ class NextcloudUserStatusClearAt_Time { try { $int = (data as int); } catch (_) {} - assert([userStatusClearAtTime0, $int].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([userStatusClearAtTime0, $int].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudUserStatusClearAt_Time( data, userStatusClearAtTime0: userStatusClearAtTime0, @@ -5271,7 +5271,7 @@ class NextcloudUserStatusPublicStatus_ClearAt { try { $int = (data as int); } catch (_) {} - assert([userStatusClearAt, $int].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([userStatusClearAt, $int].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudUserStatusPublicStatus_ClearAt( data, userStatusClearAt: userStatusClearAt, @@ -5432,7 +5432,7 @@ class NextcloudUserStatusGetPublicStatus_Ocs_Data { try { userStatusPublicStatus = NextcloudUserStatusPublicStatus.fromJson(data as Map); } catch (_) {} - assert([listDynamic, userStatusPublicStatus].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([listDynamic, userStatusPublicStatus].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudUserStatusGetPublicStatus_Ocs_Data( data, listDynamic: listDynamic, @@ -5526,7 +5526,7 @@ class NextcloudUserStatusStatus_ClearAt { try { $int = (data as int); } catch (_) {} - assert([userStatusClearAt, $int].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([userStatusClearAt, $int].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudUserStatusStatus_ClearAt( data, userStatusClearAt: userStatusClearAt, @@ -5614,7 +5614,7 @@ class NextcloudUserStatusGetStatus_Ocs_Data { try { userStatusStatus = NextcloudUserStatusStatus.fromJson(data as Map); } catch (_) {} - assert([listDynamic, userStatusStatus].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([listDynamic, userStatusStatus].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudUserStatusGetStatus_Ocs_Data( data, listDynamic: listDynamic, @@ -5707,7 +5707,7 @@ class NextcloudUserStatusPredefinedStatus_ClearAt { try { $int = (data as int); } catch (_) {} - assert([userStatusClearAt, $int].where((final x) => x != null).length == 1, 'Need oneOf for $data'); + assert([userStatusClearAt, $int].where((final x) => x != null).length >= 1, 'Need oneOf for $data'); return NextcloudUserStatusPredefinedStatus_ClearAt( data, userStatusClearAt: userStatusClearAt,