Browse Source

Merge pull request #229 from Leptopoda/fix/oneOf_assert

Relax oneOf assertion
pull/232/head
Kate 2 years ago committed by GitHub
parent
commit
234c87b150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/dynamite/lib/src/openapi_builder.dart
  2. 16
      packages/nextcloud/lib/src/nextcloud.openapi.dart

5
packages/dynamite/lib/src/openapi_builder.dart

@ -1549,7 +1549,10 @@ TypeResult resolveType(
], ],
], ],
if (schema.oneOf != null) ...[ 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(', 'return ${state.prefix}$identifier(',
'data,', 'data,',

16
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -3495,7 +3495,7 @@ class NextcloudCoreNavigationApps_Ocs_Data_Order {
try { try {
string = (data as String); string = (data as String);
} catch (_) {} } 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( return NextcloudCoreNavigationApps_Ocs_Data_Order(
data, data,
$int: $int, $int: $int,
@ -3722,7 +3722,7 @@ class NextcloudCoreAutocompleteResult_Ocs_Data_Status {
try { try {
string = (data as String); string = (data as String);
} catch (_) {} } 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( return NextcloudCoreAutocompleteResult_Ocs_Data_Status(
data, data,
listDynamic: listDynamic, listDynamic: listDynamic,
@ -5201,7 +5201,7 @@ class NextcloudUserStatusClearAt_Time {
try { try {
$int = (data as int); $int = (data as int);
} catch (_) {} } 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( return NextcloudUserStatusClearAt_Time(
data, data,
userStatusClearAtTime0: userStatusClearAtTime0, userStatusClearAtTime0: userStatusClearAtTime0,
@ -5271,7 +5271,7 @@ class NextcloudUserStatusPublicStatus_ClearAt {
try { try {
$int = (data as int); $int = (data as int);
} catch (_) {} } 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( return NextcloudUserStatusPublicStatus_ClearAt(
data, data,
userStatusClearAt: userStatusClearAt, userStatusClearAt: userStatusClearAt,
@ -5432,7 +5432,7 @@ class NextcloudUserStatusGetPublicStatus_Ocs_Data {
try { try {
userStatusPublicStatus = NextcloudUserStatusPublicStatus.fromJson(data as Map<String, dynamic>); userStatusPublicStatus = NextcloudUserStatusPublicStatus.fromJson(data as Map<String, dynamic>);
} catch (_) {} } 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( return NextcloudUserStatusGetPublicStatus_Ocs_Data(
data, data,
listDynamic: listDynamic, listDynamic: listDynamic,
@ -5526,7 +5526,7 @@ class NextcloudUserStatusStatus_ClearAt {
try { try {
$int = (data as int); $int = (data as int);
} catch (_) {} } 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( return NextcloudUserStatusStatus_ClearAt(
data, data,
userStatusClearAt: userStatusClearAt, userStatusClearAt: userStatusClearAt,
@ -5614,7 +5614,7 @@ class NextcloudUserStatusGetStatus_Ocs_Data {
try { try {
userStatusStatus = NextcloudUserStatusStatus.fromJson(data as Map<String, dynamic>); userStatusStatus = NextcloudUserStatusStatus.fromJson(data as Map<String, dynamic>);
} catch (_) {} } 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( return NextcloudUserStatusGetStatus_Ocs_Data(
data, data,
listDynamic: listDynamic, listDynamic: listDynamic,
@ -5707,7 +5707,7 @@ class NextcloudUserStatusPredefinedStatus_ClearAt {
try { try {
$int = (data as int); $int = (data as int);
} catch (_) {} } 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( return NextcloudUserStatusPredefinedStatus_ClearAt(
data, data,
userStatusClearAt: userStatusClearAt, userStatusClearAt: userStatusClearAt,

Loading…
Cancel
Save