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) ...[
"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,',

16
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<String, dynamic>);
} 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<String, dynamic>);
} 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,

Loading…
Cancel
Save