Browse Source

feat(dynamite): support optimizing someOfs

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/1178/head
Nikolas Rimikis 1 year ago
parent
commit
1aba772f1d
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 33
      packages/dynamite/dynamite/lib/src/models/type_result/some_of.dart
  2. 1
      packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart
  3. 79
      packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart
  4. 15
      packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.json
  5. 79
      packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.dart
  6. 15
      packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.json
  7. 44
      packages/dynamite/dynamite_end_to_end_test/lib/some_of.openapi.dart
  8. 35
      packages/dynamite/dynamite_end_to_end_test/test/any_of_test.dart
  9. 33
      packages/dynamite/dynamite_end_to_end_test/test/one_of_test.dart
  10. 7
      packages/neon/neon/lib/src/pages/account_settings.dart
  11. 114
      packages/nextcloud/lib/src/api/files_sharing.openapi.dart
  12. 40
      packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart
  13. 250
      packages/nextcloud/lib/src/api/provisioning_api.openapi.dart
  14. 76
      packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart

33
packages/dynamite/dynamite/lib/src/models/type_result/some_of.dart

@ -22,10 +22,14 @@ abstract class TypeResultSomeOf extends TypeResult {
return '..add(${className}Extension.serializer)';
}
late final List<TypeResult> optimizedSubTypes = subTypes.toList();
late final BuiltSet<TypeResult> optimizedSubTypes = _optimizedSubTypes.toBuiltSet();
@override
TypeResult get dartType {
if (optimizedSubTypes.isEmpty) {
throw StateError('SomeOf must have at least one sub type.');
}
if (optimizedSubTypes.length == 1) {
return optimizedSubTypes.single;
}
@ -41,6 +45,33 @@ abstract class TypeResultSomeOf extends TypeResult {
return TypeResultBase('({${record.join(',')}})');
}
Iterable<TypeResult> get _optimizedSubTypes sync* {
var optimizedNum = false;
final numbers = subTypes.where(
(final type) => switch (type.className) {
'int' || 'double' || 'num' => true,
_ => false,
},
);
if (numbers.length >= 2) {
yield TypeResultBase('num', nullable: true);
optimizedNum = true;
}
yield* subTypes.where((final type) {
if (!optimizedNum) {
return true;
}
return switch (type.className) {
'int' || 'double' || 'num' => false,
_ => true,
};
});
}
@override
bool operator ==(final Object other) =>
other is TypeResultSomeOf &&

1
packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart

@ -1,3 +1,4 @@
import 'package:built_collection/built_collection.dart';
import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:meta/meta.dart';

79
packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart

@ -220,66 +220,14 @@ typedef OneObjectAnyOf = OneObjectAnyOf0;
typedef OneValueAnyOf = String;
typedef AnyOfIntDouble = ({int? $int, double? $double});
typedef AnyOfIntDouble = num;
extension AnyOfIntDoubleExtension on AnyOfIntDouble {
List<dynamic> get _values => [$int, $double];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<AnyOfIntDouble> get serializer => const _$AnyOfIntDoubleSerializer();
static AnyOfIntDouble fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$AnyOfIntDoubleSerializer implements PrimitiveSerializer<AnyOfIntDouble> {
const _$AnyOfIntDoubleSerializer();
@override
Iterable<Type> get types => const [AnyOfIntDouble];
@override
String get wireName => 'AnyOfIntDouble';
@override
Object serialize(
final Serializers serializers,
final AnyOfIntDouble object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
}
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
typedef AnyOfIntDoubleNum = num;
@override
AnyOfIntDouble deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
return ($int: $int, $double: $double);
}
}
typedef AnyOfIntDoubleOther = ({int? $int, double? $double, String? string});
typedef AnyOfIntDoubleOther = ({num? $num, String? string});
extension AnyOfIntDoubleOtherExtension on AnyOfIntDoubleOther {
List<dynamic> get _values => [$int, $double, string];
List<dynamic> get _values => [$num, string];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<AnyOfIntDoubleOther> get serializer => const _$AnyOfIntDoubleOtherSerializer();
@ -303,13 +251,9 @@ class _$AnyOfIntDoubleOtherSerializer implements PrimitiveSerializer<AnyOfIntDou
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$int;
value = object.$num;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
}
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
return _jsonSerializers.serialize(value, specifiedType: const FullType(num))!;
}
value = object.string;
if (value != null) {
@ -324,19 +268,15 @@ class _$AnyOfIntDoubleOtherSerializer implements PrimitiveSerializer<AnyOfIntDou
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
double? $double;
num? $num;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
$num = _jsonSerializers.deserialize(data, specifiedType: const FullType(num))! as num;
} catch (_) {}
String? string;
try {
string = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String;
} catch (_) {}
return ($int: $int, $double: $double, string: string);
return ($num: $num, string: string);
}
}
@ -352,7 +292,6 @@ final Serializers _serializers = (Serializers().toBuilder()
..add(MixedAnyOfExtension.serializer)
..addBuilderFactory(const FullType(OneObjectAnyOf0), OneObjectAnyOf0.new)
..add(OneObjectAnyOf0.serializer)
..add(AnyOfIntDoubleExtension.serializer)
..add(AnyOfIntDoubleOtherExtension.serializer))
.build();

15
packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.json

@ -88,6 +88,21 @@
}
]
},
"AnyOfIntDoubleNum": {
"description": "Any of with an integer, double and number.",
"oneOf": [
{
"type": "integer"
},
{
"type": "number",
"format": "float"
},
{
"type": "number"
}
]
},
"AnyOfIntDoubleOther": {
"description": "Any of with an integer, double and other value.",
"anyOf": [

79
packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.dart

@ -220,66 +220,14 @@ typedef OneObjectOneOf = OneObjectOneOf0;
typedef OneValueOneOf = String;
typedef OneOfIntDouble = ({int? $int, double? $double});
typedef OneOfIntDouble = num;
extension OneOfIntDoubleExtension on OneOfIntDouble {
List<dynamic> get _values => [$int, $double];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<OneOfIntDouble> get serializer => const _$OneOfIntDoubleSerializer();
static OneOfIntDouble fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$OneOfIntDoubleSerializer implements PrimitiveSerializer<OneOfIntDouble> {
const _$OneOfIntDoubleSerializer();
@override
Iterable<Type> get types => const [OneOfIntDouble];
@override
String get wireName => 'OneOfIntDouble';
@override
Object serialize(
final Serializers serializers,
final OneOfIntDouble object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
}
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
typedef OneOfIntDoubleNum = num;
@override
OneOfIntDouble deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
return ($int: $int, $double: $double);
}
}
typedef OneOfIntDoubleOther = ({int? $int, double? $double, String? string});
typedef OneOfIntDoubleOther = ({num? $num, String? string});
extension OneOfIntDoubleOtherExtension on OneOfIntDoubleOther {
List<dynamic> get _values => [$int, $double, string];
List<dynamic> get _values => [$num, string];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<OneOfIntDoubleOther> get serializer => const _$OneOfIntDoubleOtherSerializer();
@ -303,13 +251,9 @@ class _$OneOfIntDoubleOtherSerializer implements PrimitiveSerializer<OneOfIntDou
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$int;
value = object.$num;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
}
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
return _jsonSerializers.serialize(value, specifiedType: const FullType(num))!;
}
value = object.string;
if (value != null) {
@ -324,19 +268,15 @@ class _$OneOfIntDoubleOtherSerializer implements PrimitiveSerializer<OneOfIntDou
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
double? $double;
num? $num;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
$num = _jsonSerializers.deserialize(data, specifiedType: const FullType(num))! as num;
} catch (_) {}
String? string;
try {
string = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String;
} catch (_) {}
return ($int: $int, $double: $double, string: string);
return ($num: $num, string: string);
}
}
@ -352,7 +292,6 @@ final Serializers _serializers = (Serializers().toBuilder()
..add(MixedOneOfExtension.serializer)
..addBuilderFactory(const FullType(OneObjectOneOf0), OneObjectOneOf0.new)
..add(OneObjectOneOf0.serializer)
..add(OneOfIntDoubleExtension.serializer)
..add(OneOfIntDoubleOtherExtension.serializer))
.build();

15
packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.json

@ -88,6 +88,21 @@
}
]
},
"OneOfIntDoubleNum": {
"description": "One of with an integer, double and number.",
"oneOf": [
{
"type": "integer"
},
{
"type": "number",
"format": "float"
},
{
"type": "number"
}
]
},
"OneOfIntDoubleOther": {
"description": "One of with an integer, double and other value.",
"oneOf": [

44
packages/dynamite/dynamite_end_to_end_test/lib/some_of.openapi.dart

@ -28,10 +28,10 @@ class Client extends DynamiteClient {
);
}
typedef OneOfIntDoubleOther = ({int? $int, double? $double, String? string});
typedef OneOfIntDoubleOther = ({num? $num, String? string});
extension OneOfIntDoubleOtherExtension on OneOfIntDoubleOther {
List<dynamic> get _values => [$int, $double, string];
List<dynamic> get _values => [$num, string];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<OneOfIntDoubleOther> get serializer => const _$OneOfIntDoubleOtherSerializer();
@ -55,13 +55,9 @@ class _$OneOfIntDoubleOtherSerializer implements PrimitiveSerializer<OneOfIntDou
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$int;
value = object.$num;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
}
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
return _jsonSerializers.serialize(value, specifiedType: const FullType(num))!;
}
value = object.string;
if (value != null) {
@ -76,26 +72,22 @@ class _$OneOfIntDoubleOtherSerializer implements PrimitiveSerializer<OneOfIntDou
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
double? $double;
num? $num;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
$num = _jsonSerializers.deserialize(data, specifiedType: const FullType(num))! as num;
} catch (_) {}
String? string;
try {
string = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String;
} catch (_) {}
return ($int: $int, $double: $double, string: string);
return ($num: $num, string: string);
}
}
typedef AnyOfIntDoubleOther = ({int? $int, double? $double, String? string});
typedef AnyOfIntDoubleOther = ({num? $num, String? string});
extension AnyOfIntDoubleOtherExtension on AnyOfIntDoubleOther {
List<dynamic> get _values => [$int, $double, string];
List<dynamic> get _values => [$num, string];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<AnyOfIntDoubleOther> get serializer => const _$AnyOfIntDoubleOtherSerializer();
@ -119,13 +111,9 @@ class _$AnyOfIntDoubleOtherSerializer implements PrimitiveSerializer<AnyOfIntDou
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$int;
value = object.$num;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
}
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
return _jsonSerializers.serialize(value, specifiedType: const FullType(num))!;
}
value = object.string;
if (value != null) {
@ -140,19 +128,15 @@ class _$AnyOfIntDoubleOtherSerializer implements PrimitiveSerializer<AnyOfIntDou
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
double? $double;
num? $num;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
$num = _jsonSerializers.deserialize(data, specifiedType: const FullType(num))! as num;
} catch (_) {}
String? string;
try {
string = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String;
} catch (_) {}
return ($int: $int, $double: $double, string: string);
return ($num: $num, string: string);
}
}

35
packages/dynamite/dynamite_end_to_end_test/test/any_of_test.dart

@ -62,31 +62,24 @@ void main() {
});
test('AnyOfIntDouble', () {
AnyOfIntDouble object = (
$double: 0.5971645863260784,
$int: null,
);
Object? json = 0.5971645863260784;
expect(object.toJson(), equals(json));
expect(AnyOfIntDoubleExtension.fromJson(json), equals(object));
Object? object = 0.5971645863260784;
expect(object, isA<AnyOfIntDouble>());
object = (
$double: null,
$int: 361,
);
object = 361;
expect(object, isA<AnyOfIntDouble>());
});
json = 361;
test('AnyOfIntDoubleNum', () {
Object? object = 0.5213515036646204;
expect(object, isA<AnyOfIntDoubleNum>());
expect(object.toJson(), equals(json));
expect(AnyOfIntDoubleExtension.fromJson(json), equals(object));
object = 620;
expect(object, isA<AnyOfIntDoubleNum>());
});
test('AnyOfIntDoubleOther', () {
AnyOfIntDoubleOther object = (
$double: 0.5971645863260784,
$int: null,
$num: 0.5971645863260784,
string: null,
);
@ -96,8 +89,7 @@ void main() {
expect(AnyOfIntDoubleOtherExtension.fromJson(json), equals(object));
object = (
$double: null,
$int: 361,
$num: 361,
string: null,
);
@ -107,8 +99,7 @@ void main() {
expect(AnyOfIntDoubleOtherExtension.fromJson(json)..validateAnyOf(), equals(object));
object = (
$double: null,
$int: null,
$num: null,
string: 'string',
);

33
packages/dynamite/dynamite_end_to_end_test/test/one_of_test.dart

@ -62,31 +62,26 @@ void main() {
});
test('OneOfIntDouble', () {
OneOfIntDouble object = (
$double: 0.5971645863260784,
$int: null,
);
Object? object = 0.5971645863260784;
Object? json = 0.5971645863260784;
expect(object, isA<OneOfIntDouble>());
expect(object.toJson(), equals(json));
expect(OneOfIntDoubleExtension.fromJson(json), equals(object));
object = 361;
expect(object, isA<OneOfIntDouble>());
});
object = (
$double: null,
$int: 361,
);
test('OneOfIntDoubleNum', () {
Object? object = 0.6748612915546136;
json = 361;
expect(object, isA<OneOfIntDoubleNum>());
expect(object.toJson(), equals(json));
expect(OneOfIntDoubleExtension.fromJson(json), equals(object));
object = 769;
expect(object, isA<OneOfIntDoubleNum>());
});
test('OneOfIntDoubleOther', () {
OneOfIntDoubleOther object = (
$double: 0.5971645863260784,
$int: null,
$num: 0.5971645863260784,
string: null,
);
@ -96,8 +91,7 @@ void main() {
expect(OneOfIntDoubleOtherExtension.fromJson(json), equals(object));
object = (
$double: null,
$int: 361,
$num: 361,
string: null,
);
@ -107,8 +101,7 @@ void main() {
expect(OneOfIntDoubleOtherExtension.fromJson(json), equals(object));
object = (
$double: null,
$int: null,
$num: null,
string: 'string',
);

7
packages/neon/neon/lib/src/pages/account_settings.dart

@ -103,10 +103,9 @@ class AccountSettingsPage extends StatelessWidget {
double? value;
Widget? subtitle;
if (userDetails.hasData) {
final quotaRelative =
userDetails.data?.quota.relative?.$int ?? userDetails.data?.quota.relative?.$double ?? 0;
final quotaTotal = userDetails.data?.quota.total?.$int ?? userDetails.data?.quota.total?.$double ?? 0;
final quotaUsed = userDetails.data?.quota.used?.$int ?? userDetails.data?.quota.used?.$double ?? 0;
final quotaRelative = userDetails.data?.quota.relative ?? 0;
final quotaTotal = userDetails.data?.quota.total ?? 0;
final quotaUsed = userDetails.data?.quota.used ?? 0;
value = quotaRelative / 100;
subtitle = Text(

114
packages/nextcloud/lib/src/api/files_sharing.openapi.dart

@ -4851,117 +4851,9 @@ abstract class Capabilities implements CapabilitiesInterface, Built<Capabilities
static Serializer<Capabilities> get serializer => _$capabilitiesSerializer;
}
typedef ShareInfo_Size = ({int? $int, double? $double});
typedef ShareInfo_Size = num;
extension ShareInfo_SizeExtension on ShareInfo_Size {
List<dynamic> get _values => [$int, $double];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<ShareInfo_Size> get serializer => const _$ShareInfo_SizeSerializer();
static ShareInfo_Size fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$ShareInfo_SizeSerializer implements PrimitiveSerializer<ShareInfo_Size> {
const _$ShareInfo_SizeSerializer();
@override
Iterable<Type> get types => const [ShareInfo_Size];
@override
String get wireName => 'ShareInfo_Size';
@override
Object serialize(
final Serializers serializers,
final ShareInfo_Size object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
}
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
@override
ShareInfo_Size deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
return ($int: $int, $double: $double);
}
}
typedef Share_ItemSize = ({double? $double, int? $int});
extension Share_ItemSizeExtension on Share_ItemSize {
List<dynamic> get _values => [$double, $int];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<Share_ItemSize> get serializer => const _$Share_ItemSizeSerializer();
static Share_ItemSize fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$Share_ItemSizeSerializer implements PrimitiveSerializer<Share_ItemSize> {
const _$Share_ItemSizeSerializer();
@override
Iterable<Type> get types => const [Share_ItemSize];
@override
String get wireName => 'Share_ItemSize';
@override
Object serialize(
final Serializers serializers,
final Share_ItemSize object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
}
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
@override
Share_ItemSize deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
return ($double: $double, $int: $int);
}
}
typedef Share_ItemSize = num;
typedef ShareesapiSearchShareType = ({int? $int, BuiltList<int>? builtListInt});
@ -5172,7 +5064,6 @@ final Serializers _serializers = (Serializers().toBuilder()
..add(RemoteUnshareResponseApplicationJson_Ocs.serializer)
..addBuilderFactory(const FullType(ShareInfo), ShareInfo.new)
..add(ShareInfo.serializer)
..add(ShareInfo_SizeExtension.serializer)
..addBuilderFactory(
const FullType(BuiltMap, [FullType(String), FullType(JsonObject)]),
MapBuilder<String, JsonObject>.new,
@ -5195,7 +5086,6 @@ final Serializers _serializers = (Serializers().toBuilder()
..add(ShareapiGetSharesResponseApplicationJson_Ocs.serializer)
..addBuilderFactory(const FullType(Share), Share.new)
..add(Share.serializer)
..add(Share_ItemSizeExtension.serializer)
..add(Share_ItemType.serializer)
..addBuilderFactory(const FullType(Share_Status), Share_Status.new)
..add(Share_Status.serializer)

40
packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart

@ -1267,7 +1267,7 @@ class _$ShareInfoSerializer implements StructuredSerializer<ShareInfo> {
'mimetype',
serializers.serialize(object.mimetype, specifiedType: const FullType(String)),
'size',
serializers.serialize(object.size, specifiedType: const FullType(ShareInfo_Size)),
serializers.serialize(object.size, specifiedType: const FullType(num)),
'type',
serializers.serialize(object.type, specifiedType: const FullType(String)),
'etag',
@ -1316,8 +1316,7 @@ class _$ShareInfoSerializer implements StructuredSerializer<ShareInfo> {
result.mimetype = serializers.deserialize(value, specifiedType: const FullType(String))! as String;
break;
case 'size':
result.size =
serializers.deserialize(value, specifiedType: const FullType(ShareInfo_Size))! as ShareInfo_Size;
result.size = serializers.deserialize(value, specifiedType: const FullType(num))! as num;
break;
case 'type':
result.type = serializers.deserialize(value, specifiedType: const FullType(String))! as String;
@ -1454,7 +1453,7 @@ class _$ShareSerializer implements StructuredSerializer<Share> {
'item_mtime',
serializers.serialize(object.itemMtime, specifiedType: const FullType(int)),
'item_size',
serializers.serialize(object.itemSize, specifiedType: const FullType(Share_ItemSize)),
serializers.serialize(object.itemSize, specifiedType: const FullType(num)),
'item_source',
serializers.serialize(object.itemSource, specifiedType: const FullType(int)),
'item_type',
@ -1637,8 +1636,7 @@ class _$ShareSerializer implements StructuredSerializer<Share> {
result.itemPermissions = serializers.deserialize(value, specifiedType: const FullType(int)) as int?;
break;
case 'item_size':
result.itemSize =
serializers.deserialize(value, specifiedType: const FullType(Share_ItemSize))! as Share_ItemSize;
result.itemSize = serializers.deserialize(value, specifiedType: const FullType(num))! as num;
break;
case 'item_source':
result.itemSource = serializers.deserialize(value, specifiedType: const FullType(int))! as int;
@ -7374,8 +7372,8 @@ abstract mixin class ShareInfoInterfaceBuilder {
String? get mimetype;
set mimetype(String? mimetype);
ShareInfo_Size? get size;
set size(ShareInfo_Size? size);
num? get size;
set size(num? size);
String? get type;
set type(String? type);
@ -7401,7 +7399,7 @@ class _$ShareInfo extends ShareInfo {
@override
final String mimetype;
@override
final ShareInfo_Size size;
final num size;
@override
final String type;
@override
@ -7443,7 +7441,6 @@ class _$ShareInfo extends ShareInfo {
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
final dynamic _$dynamicOther = other;
return other is ShareInfo &&
id == other.id &&
parentId == other.parentId &&
@ -7451,7 +7448,7 @@ class _$ShareInfo extends ShareInfo {
name == other.name &&
permissions == other.permissions &&
mimetype == other.mimetype &&
size == _$dynamicOther.size &&
size == other.size &&
type == other.type &&
etag == other.etag &&
children == other.children;
@ -7518,9 +7515,9 @@ class ShareInfoBuilder implements Builder<ShareInfo, ShareInfoBuilder>, ShareInf
String? get mimetype => _$this._mimetype;
set mimetype(covariant String? mimetype) => _$this._mimetype = mimetype;
ShareInfo_Size? _size;
ShareInfo_Size? get size => _$this._size;
set size(covariant ShareInfo_Size? size) => _$this._size = size;
num? _size;
num? get size => _$this._size;
set size(covariant num? size) => _$this._size = size;
String? _type;
String? get type => _$this._type;
@ -7767,8 +7764,8 @@ abstract mixin class ShareInterfaceBuilder {
int? get itemPermissions;
set itemPermissions(int? itemPermissions);
Share_ItemSize? get itemSize;
set itemSize(Share_ItemSize? itemSize);
num? get itemSize;
set itemSize(num? itemSize);
int? get itemSource;
set itemSource(int? itemSource);
@ -7879,7 +7876,7 @@ class _$Share extends Share {
@override
final int? itemPermissions;
@override
final Share_ItemSize itemSize;
final num itemSize;
@override
final int itemSource;
@override
@ -8014,7 +8011,6 @@ class _$Share extends Share {
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
final dynamic _$dynamicOther = other;
return other is Share &&
attributes == other.attributes &&
canDelete == other.canDelete &&
@ -8030,7 +8026,7 @@ class _$Share extends Share {
id == other.id &&
itemMtime == other.itemMtime &&
itemPermissions == other.itemPermissions &&
itemSize == _$dynamicOther.itemSize &&
itemSize == other.itemSize &&
itemSource == other.itemSource &&
itemType == other.itemType &&
label == other.label &&
@ -8215,9 +8211,9 @@ class ShareBuilder implements Builder<Share, ShareBuilder>, ShareInterfaceBuilde
int? get itemPermissions => _$this._itemPermissions;
set itemPermissions(covariant int? itemPermissions) => _$this._itemPermissions = itemPermissions;
Share_ItemSize? _itemSize;
Share_ItemSize? get itemSize => _$this._itemSize;
set itemSize(covariant Share_ItemSize? itemSize) => _$this._itemSize = itemSize;
num? _itemSize;
num? get itemSize => _$this._itemSize;
set itemSize(covariant num? itemSize) => _$this._itemSize = itemSize;
int? _itemSource;
int? get itemSource => _$this._itemSource;

250
packages/nextcloud/lib/src/api/provisioning_api.openapi.dart

@ -8184,66 +8184,12 @@ class _$GroupDetails_DisabledSerializer implements PrimitiveSerializer<GroupDeta
}
}
typedef UserDetailsQuota_Free = ({double? $double, int? $int});
typedef UserDetailsQuota_Free = num;
extension UserDetailsQuota_FreeExtension on UserDetailsQuota_Free {
List<dynamic> get _values => [$double, $int];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<UserDetailsQuota_Free> get serializer => const _$UserDetailsQuota_FreeSerializer();
static UserDetailsQuota_Free fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$UserDetailsQuota_FreeSerializer implements PrimitiveSerializer<UserDetailsQuota_Free> {
const _$UserDetailsQuota_FreeSerializer();
@override
Iterable<Type> get types => const [UserDetailsQuota_Free];
@override
String get wireName => 'UserDetailsQuota_Free';
@override
Object serialize(
final Serializers serializers,
final UserDetailsQuota_Free object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
}
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
@override
UserDetailsQuota_Free deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
return ($double: $double, $int: $int);
}
}
typedef UserDetailsQuota_Quota = ({double? $double, int? $int, String? string});
typedef UserDetailsQuota_Quota = ({num? $num, String? string});
extension UserDetailsQuota_QuotaExtension on UserDetailsQuota_Quota {
List<dynamic> get _values => [$double, $int, string];
List<dynamic> get _values => [$num, string];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<UserDetailsQuota_Quota> get serializer => const _$UserDetailsQuota_QuotaSerializer();
@ -8267,13 +8213,9 @@ class _$UserDetailsQuota_QuotaSerializer implements PrimitiveSerializer<UserDeta
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
}
value = object.$int;
value = object.$num;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
return _jsonSerializers.serialize(value, specifiedType: const FullType(num))!;
}
value = object.string;
if (value != null) {
@ -8288,189 +8230,23 @@ class _$UserDetailsQuota_QuotaSerializer implements PrimitiveSerializer<UserDeta
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
int? $int;
num? $num;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
$num = _jsonSerializers.deserialize(data, specifiedType: const FullType(num))! as num;
} catch (_) {}
String? string;
try {
string = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String;
} catch (_) {}
return ($double: $double, $int: $int, string: string);
}
}
typedef UserDetailsQuota_Relative = ({double? $double, int? $int});
extension UserDetailsQuota_RelativeExtension on UserDetailsQuota_Relative {
List<dynamic> get _values => [$double, $int];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<UserDetailsQuota_Relative> get serializer => const _$UserDetailsQuota_RelativeSerializer();
static UserDetailsQuota_Relative fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$UserDetailsQuota_RelativeSerializer implements PrimitiveSerializer<UserDetailsQuota_Relative> {
const _$UserDetailsQuota_RelativeSerializer();
@override
Iterable<Type> get types => const [UserDetailsQuota_Relative];
@override
String get wireName => 'UserDetailsQuota_Relative';
@override
Object serialize(
final Serializers serializers,
final UserDetailsQuota_Relative object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
}
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
@override
UserDetailsQuota_Relative deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
return ($double: $double, $int: $int);
}
}
typedef UserDetailsQuota_Total = ({double? $double, int? $int});
extension UserDetailsQuota_TotalExtension on UserDetailsQuota_Total {
List<dynamic> get _values => [$double, $int];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<UserDetailsQuota_Total> get serializer => const _$UserDetailsQuota_TotalSerializer();
static UserDetailsQuota_Total fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$UserDetailsQuota_TotalSerializer implements PrimitiveSerializer<UserDetailsQuota_Total> {
const _$UserDetailsQuota_TotalSerializer();
@override
Iterable<Type> get types => const [UserDetailsQuota_Total];
@override
String get wireName => 'UserDetailsQuota_Total';
@override
Object serialize(
final Serializers serializers,
final UserDetailsQuota_Total object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
}
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
@override
UserDetailsQuota_Total deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
return ($double: $double, $int: $int);
return ($num: $num, string: string);
}
}
typedef UserDetailsQuota_Used = ({double? $double, int? $int});
typedef UserDetailsQuota_Relative = num;
extension UserDetailsQuota_UsedExtension on UserDetailsQuota_Used {
List<dynamic> get _values => [$double, $int];
void validateOneOf() => dynamite_utils.validateOneOf(_values);
void validateAnyOf() => dynamite_utils.validateAnyOf(_values);
static Serializer<UserDetailsQuota_Used> get serializer => const _$UserDetailsQuota_UsedSerializer();
static UserDetailsQuota_Used fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!;
Object? toJson() => _jsonSerializers.serializeWith(serializer, this);
}
class _$UserDetailsQuota_UsedSerializer implements PrimitiveSerializer<UserDetailsQuota_Used> {
const _$UserDetailsQuota_UsedSerializer();
@override
Iterable<Type> get types => const [UserDetailsQuota_Used];
typedef UserDetailsQuota_Total = num;
@override
String get wireName => 'UserDetailsQuota_Used';
@override
Object serialize(
final Serializers serializers,
final UserDetailsQuota_Used object, {
final FullType specifiedType = FullType.unspecified,
}) {
dynamic value;
value = object.$double;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!;
}
value = object.$int;
if (value != null) {
return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!;
} // Should not be possible after validation.
throw StateError('Tried to serialize without any value.');
}
@override
UserDetailsQuota_Used deserialize(
final Serializers serializers,
final Object data, {
final FullType specifiedType = FullType.unspecified,
}) {
double? $double;
try {
$double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double;
} catch (_) {}
int? $int;
try {
$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int;
} catch (_) {}
return ($double: $double, $int: $int);
}
}
typedef UserDetailsQuota_Used = num;
typedef GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users = ({
UserDetails? userDetails,
@ -8882,11 +8658,7 @@ final Serializers _serializers = (Serializers().toBuilder()
..add(UserDetails_BackendCapabilities.serializer)
..addBuilderFactory(const FullType(UserDetailsQuota), UserDetailsQuota.new)
..add(UserDetailsQuota.serializer)
..add(UserDetailsQuota_FreeExtension.serializer)
..add(UserDetailsQuota_QuotaExtension.serializer)
..add(UserDetailsQuota_RelativeExtension.serializer)
..add(UserDetailsQuota_TotalExtension.serializer)
..add(UserDetailsQuota_UsedExtension.serializer)
..addBuilderFactory(
const FullType(GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users1),
GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users1.new,

76
packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart

@ -2304,7 +2304,7 @@ class _$UserDetailsQuotaSerializer implements StructuredSerializer<UserDetailsQu
if (value != null) {
result
..add('free')
..add(serializers.serialize(value, specifiedType: const FullType(UserDetailsQuota_Free)));
..add(serializers.serialize(value, specifiedType: const FullType(num)));
}
value = object.quota;
if (value != null) {
@ -2316,19 +2316,19 @@ class _$UserDetailsQuotaSerializer implements StructuredSerializer<UserDetailsQu
if (value != null) {
result
..add('relative')
..add(serializers.serialize(value, specifiedType: const FullType(UserDetailsQuota_Relative)));
..add(serializers.serialize(value, specifiedType: const FullType(num)));
}
value = object.total;
if (value != null) {
result
..add('total')
..add(serializers.serialize(value, specifiedType: const FullType(UserDetailsQuota_Total)));
..add(serializers.serialize(value, specifiedType: const FullType(num)));
}
value = object.used;
if (value != null) {
result
..add('used')
..add(serializers.serialize(value, specifiedType: const FullType(UserDetailsQuota_Used)));
..add(serializers.serialize(value, specifiedType: const FullType(num)));
}
return result;
}
@ -2345,24 +2345,20 @@ class _$UserDetailsQuotaSerializer implements StructuredSerializer<UserDetailsQu
final Object? value = iterator.current;
switch (key) {
case 'free':
result.free = serializers.deserialize(value, specifiedType: const FullType(UserDetailsQuota_Free))
as UserDetailsQuota_Free?;
result.free = serializers.deserialize(value, specifiedType: const FullType(num)) as num?;
break;
case 'quota':
result.quota = serializers.deserialize(value, specifiedType: const FullType(UserDetailsQuota_Quota))
as UserDetailsQuota_Quota?;
break;
case 'relative':
result.relative = serializers.deserialize(value, specifiedType: const FullType(UserDetailsQuota_Relative))
as UserDetailsQuota_Relative?;
result.relative = serializers.deserialize(value, specifiedType: const FullType(num)) as num?;
break;
case 'total':
result.total = serializers.deserialize(value, specifiedType: const FullType(UserDetailsQuota_Total))
as UserDetailsQuota_Total?;
result.total = serializers.deserialize(value, specifiedType: const FullType(num)) as num?;
break;
case 'used':
result.used = serializers.deserialize(value, specifiedType: const FullType(UserDetailsQuota_Used))
as UserDetailsQuota_Used?;
result.used = serializers.deserialize(value, specifiedType: const FullType(num)) as num?;
break;
}
}
@ -10786,33 +10782,33 @@ class UserDetails_BackendCapabilitiesBuilder
abstract mixin class UserDetailsQuotaInterfaceBuilder {
void replace(UserDetailsQuotaInterface other);
void update(void Function(UserDetailsQuotaInterfaceBuilder) updates);
UserDetailsQuota_Free? get free;
set free(UserDetailsQuota_Free? free);
num? get free;
set free(num? free);
UserDetailsQuota_Quota? get quota;
set quota(UserDetailsQuota_Quota? quota);
UserDetailsQuota_Relative? get relative;
set relative(UserDetailsQuota_Relative? relative);
num? get relative;
set relative(num? relative);
UserDetailsQuota_Total? get total;
set total(UserDetailsQuota_Total? total);
num? get total;
set total(num? total);
UserDetailsQuota_Used? get used;
set used(UserDetailsQuota_Used? used);
num? get used;
set used(num? used);
}
class _$UserDetailsQuota extends UserDetailsQuota {
@override
final UserDetailsQuota_Free? free;
final num? free;
@override
final UserDetailsQuota_Quota? quota;
@override
final UserDetailsQuota_Relative? relative;
final num? relative;
@override
final UserDetailsQuota_Total? total;
final num? total;
@override
final UserDetailsQuota_Used? used;
final num? used;
factory _$UserDetailsQuota([void Function(UserDetailsQuotaBuilder)? updates]) =>
(UserDetailsQuotaBuilder()..update(updates))._build();
@ -10830,11 +10826,11 @@ class _$UserDetailsQuota extends UserDetailsQuota {
if (identical(other, this)) return true;
final dynamic _$dynamicOther = other;
return other is UserDetailsQuota &&
free == _$dynamicOther.free &&
free == other.free &&
quota == _$dynamicOther.quota &&
relative == _$dynamicOther.relative &&
total == _$dynamicOther.total &&
used == _$dynamicOther.used;
relative == other.relative &&
total == other.total &&
used == other.used;
}
@override
@ -10865,25 +10861,25 @@ class UserDetailsQuotaBuilder
implements Builder<UserDetailsQuota, UserDetailsQuotaBuilder>, UserDetailsQuotaInterfaceBuilder {
_$UserDetailsQuota? _$v;
UserDetailsQuota_Free? _free;
UserDetailsQuota_Free? get free => _$this._free;
set free(covariant UserDetailsQuota_Free? free) => _$this._free = free;
num? _free;
num? get free => _$this._free;
set free(covariant num? free) => _$this._free = free;
UserDetailsQuota_Quota? _quota;
UserDetailsQuota_Quota? get quota => _$this._quota;
set quota(covariant UserDetailsQuota_Quota? quota) => _$this._quota = quota;
UserDetailsQuota_Relative? _relative;
UserDetailsQuota_Relative? get relative => _$this._relative;
set relative(covariant UserDetailsQuota_Relative? relative) => _$this._relative = relative;
num? _relative;
num? get relative => _$this._relative;
set relative(covariant num? relative) => _$this._relative = relative;
UserDetailsQuota_Total? _total;
UserDetailsQuota_Total? get total => _$this._total;
set total(covariant UserDetailsQuota_Total? total) => _$this._total = total;
num? _total;
num? get total => _$this._total;
set total(covariant num? total) => _$this._total = total;
UserDetailsQuota_Used? _used;
UserDetailsQuota_Used? get used => _$this._used;
set used(covariant UserDetailsQuota_Used? used) => _$this._used = used;
num? _used;
num? get used => _$this._used;
set used(covariant num? used) => _$this._used = used;
UserDetailsQuotaBuilder();

Loading…
Cancel
Save