Skip to content

Commit

Permalink
feat(dynamite): Remove need for double fix and format
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Apr 4, 2024
1 parent 207623c commit a6cc324
Show file tree
Hide file tree
Showing 16 changed files with 317 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ sealed class TypeResult {
..write(serializerName ?? r'_$jsonSerializers')
..write('.deserialize(')
..write(object)
..write(', specifiedType: $fullType)');
..write(',\n')
..write('specifiedType: ')
..write(fullType)
..write(',\n')
..write(')');

if (!nullable) {
buffer.write('!');
Expand Down
30 changes: 24 additions & 6 deletions packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,17 @@ class _$0c9017d9a03ba2eb2f15acadeab85bbeSerializer implements PrimitiveSerialize
}) {
ObjectAnyOf0? objectAnyOf0;
try {
objectAnyOf0 = serializers.deserialize(data, specifiedType: const FullType(ObjectAnyOf0))! as ObjectAnyOf0;
objectAnyOf0 = serializers.deserialize(
data,
specifiedType: const FullType(ObjectAnyOf0),
)! as ObjectAnyOf0;
} catch (_) {}
ObjectAnyOf1? objectAnyOf1;
try {
objectAnyOf1 = serializers.deserialize(data, specifiedType: const FullType(ObjectAnyOf1))! as ObjectAnyOf1;
objectAnyOf1 = serializers.deserialize(
data,
specifiedType: const FullType(ObjectAnyOf1),
)! as ObjectAnyOf1;
} catch (_) {}
return (objectAnyOf0: objectAnyOf0, objectAnyOf1: objectAnyOf1);
}
Expand Down Expand Up @@ -313,11 +319,17 @@ class _$fba45e085ee99d64c5141852d4323e3dSerializer implements PrimitiveSerialize
}) {
MixedAnyOf1? mixedAnyOf1;
try {
mixedAnyOf1 = serializers.deserialize(data, specifiedType: const FullType(MixedAnyOf1))! as MixedAnyOf1;
mixedAnyOf1 = serializers.deserialize(
data,
specifiedType: const FullType(MixedAnyOf1),
)! as MixedAnyOf1;
} catch (_) {}
String? string;
try {
string = serializers.deserialize(data, specifiedType: const FullType(String))! as String;
string = serializers.deserialize(
data,
specifiedType: const FullType(String),
)! as String;
} catch (_) {}
return (mixedAnyOf1: mixedAnyOf1, string: string);
}
Expand Down Expand Up @@ -389,11 +401,17 @@ class _$b6d67dc2a96424d2f407f8e51557f3deSerializer implements PrimitiveSerialize
}) {
num? $num;
try {
$num = serializers.deserialize(data, specifiedType: const FullType(num))! as num;
$num = serializers.deserialize(
data,
specifiedType: const FullType(num),
)! as num;
} catch (_) {}
String? string;
try {
string = serializers.deserialize(data, specifiedType: const FullType(String))! as String;
string = serializers.deserialize(
data,
specifiedType: const FullType(String),
)! as String;
} catch (_) {}
return ($num: $num, string: string);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,17 @@ class _$b2c4857c0136baea42828d89c87c757dSerializer implements PrimitiveSerialize
}) {
int? $int;
try {
$int = serializers.deserialize(data, specifiedType: const FullType(int))! as int;
$int = serializers.deserialize(
data,
specifiedType: const FullType(int),
)! as int;
} catch (_) {}
String? string;
try {
string = serializers.deserialize(data, specifiedType: const FullType(String))! as String;
string = serializers.deserialize(
data,
specifiedType: const FullType(String),
)! as String;
} catch (_) {}
return ($int: $int, string: string);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,17 @@ class _$fc0451dbdd462718bd075afd2e3ce0ecSerializer implements PrimitiveSerialize
}) {
BaseOneOf1? baseOneOf1;
try {
baseOneOf1 = serializers.deserialize(data, specifiedType: const FullType(BaseOneOf1))! as BaseOneOf1;
baseOneOf1 = serializers.deserialize(
data,
specifiedType: const FullType(BaseOneOf1),
)! as BaseOneOf1;
} catch (_) {}
double? $double;
try {
$double = serializers.deserialize(data, specifiedType: const FullType(double))! as double;
$double = serializers.deserialize(
data,
specifiedType: const FullType(double),
)! as double;
} catch (_) {}
return (baseOneOf1: baseOneOf1, $double: $double);
}
Expand Down Expand Up @@ -404,11 +410,17 @@ class _$ce3c7b262d1c503446a436c461be5be9Serializer implements PrimitiveSerialize
}) {
BaseAnyOf1? baseAnyOf1;
try {
baseAnyOf1 = serializers.deserialize(data, specifiedType: const FullType(BaseAnyOf1))! as BaseAnyOf1;
baseAnyOf1 = serializers.deserialize(
data,
specifiedType: const FullType(BaseAnyOf1),
)! as BaseAnyOf1;
} catch (_) {}
int? $int;
try {
$int = serializers.deserialize(data, specifiedType: const FullType(int))! as int;
$int = serializers.deserialize(
data,
specifiedType: const FullType(int),
)! as int;
} catch (_) {}
return (baseAnyOf1: baseAnyOf1, $int: $int);
}
Expand Down Expand Up @@ -498,25 +510,39 @@ class _$8da5087c0b3f2cce06998d453af8ad19Serializer implements PrimitiveSerialize
}) {
BaseAllOf? baseAllOf;
try {
baseAllOf = serializers.deserialize(data, specifiedType: const FullType(BaseAllOf))! as BaseAllOf;
baseAllOf = serializers.deserialize(
data,
specifiedType: const FullType(BaseAllOf),
)! as BaseAllOf;
} catch (_) {}
BaseAnyOf? baseAnyOf;
try {
baseAnyOf = (serializers.deserialize(data, specifiedType: const FullType(BaseAnyOf))! as BaseAnyOf)
baseAnyOf = (serializers.deserialize(
data,
specifiedType: const FullType(BaseAnyOf),
)! as BaseAnyOf)
..validateAnyOf();
} catch (_) {}
BaseNestedOneOf3? baseNestedOneOf3;
try {
baseNestedOneOf3 =
serializers.deserialize(data, specifiedType: const FullType(BaseNestedOneOf3))! as BaseNestedOneOf3;
baseNestedOneOf3 = serializers.deserialize(
data,
specifiedType: const FullType(BaseNestedOneOf3),
)! as BaseNestedOneOf3;
} catch (_) {}
BaseOneOf1? baseOneOf1;
try {
baseOneOf1 = serializers.deserialize(data, specifiedType: const FullType(BaseOneOf1))! as BaseOneOf1;
baseOneOf1 = serializers.deserialize(
data,
specifiedType: const FullType(BaseOneOf1),
)! as BaseOneOf1;
} catch (_) {}
double? $double;
try {
$double = serializers.deserialize(data, specifiedType: const FullType(double))! as double;
$double = serializers.deserialize(
data,
specifiedType: const FullType(double),
)! as double;
} catch (_) {}
return (
baseAllOf: baseAllOf,
Expand Down Expand Up @@ -612,25 +638,39 @@ class _$523892e2348458a2bdb28f9f942dca37Serializer implements PrimitiveSerialize
}) {
BaseAllOf? baseAllOf;
try {
baseAllOf = serializers.deserialize(data, specifiedType: const FullType(BaseAllOf))! as BaseAllOf;
baseAllOf = serializers.deserialize(
data,
specifiedType: const FullType(BaseAllOf),
)! as BaseAllOf;
} catch (_) {}
BaseAnyOf1? baseAnyOf1;
try {
baseAnyOf1 = serializers.deserialize(data, specifiedType: const FullType(BaseAnyOf1))! as BaseAnyOf1;
baseAnyOf1 = serializers.deserialize(
data,
specifiedType: const FullType(BaseAnyOf1),
)! as BaseAnyOf1;
} catch (_) {}
BaseNestedAnyOf3? baseNestedAnyOf3;
try {
baseNestedAnyOf3 =
serializers.deserialize(data, specifiedType: const FullType(BaseNestedAnyOf3))! as BaseNestedAnyOf3;
baseNestedAnyOf3 = serializers.deserialize(
data,
specifiedType: const FullType(BaseNestedAnyOf3),
)! as BaseNestedAnyOf3;
} catch (_) {}
BaseOneOf? baseOneOf;
try {
baseOneOf = (serializers.deserialize(data, specifiedType: const FullType(BaseOneOf))! as BaseOneOf)
baseOneOf = (serializers.deserialize(
data,
specifiedType: const FullType(BaseOneOf),
)! as BaseOneOf)
..validateOneOf();
} catch (_) {}
int? $int;
try {
$int = serializers.deserialize(data, specifiedType: const FullType(int))! as int;
$int = serializers.deserialize(
data,
specifiedType: const FullType(int),
)! as int;
} catch (_) {}
return (
baseAllOf: baseAllOf,
Expand Down Expand Up @@ -708,11 +748,17 @@ class _$abe6d27882a5771a98ede04cd64de567Serializer implements PrimitiveSerialize
}) {
BaseOneOf1? baseOneOf1;
try {
baseOneOf1 = serializers.deserialize(data, specifiedType: const FullType(BaseOneOf1))! as BaseOneOf1;
baseOneOf1 = serializers.deserialize(
data,
specifiedType: const FullType(BaseOneOf1),
)! as BaseOneOf1;
} catch (_) {}
num? $num;
try {
$num = serializers.deserialize(data, specifiedType: const FullType(num))! as num;
$num = serializers.deserialize(
data,
specifiedType: const FullType(num),
)! as num;
} catch (_) {}
return (baseOneOf1: baseOneOf1, $num: $num);
}
Expand Down
48 changes: 36 additions & 12 deletions packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,17 @@ class _$6c828020e1dac1d58ded0a29ef8b0c41Serializer implements PrimitiveSerialize
}) {
ObjectOneOf0? objectOneOf0;
try {
objectOneOf0 = serializers.deserialize(data, specifiedType: const FullType(ObjectOneOf0))! as ObjectOneOf0;
objectOneOf0 = serializers.deserialize(
data,
specifiedType: const FullType(ObjectOneOf0),
)! as ObjectOneOf0;
} catch (_) {}
ObjectOneOf1? objectOneOf1;
try {
objectOneOf1 = serializers.deserialize(data, specifiedType: const FullType(ObjectOneOf1))! as ObjectOneOf1;
objectOneOf1 = serializers.deserialize(
data,
specifiedType: const FullType(ObjectOneOf1),
)! as ObjectOneOf1;
} catch (_) {}
return (objectOneOf0: objectOneOf0, objectOneOf1: objectOneOf1);
}
Expand Down Expand Up @@ -401,11 +407,17 @@ class _$d1b40dfcebdca2dfa1f3e52ac98462a5Serializer implements PrimitiveSerialize
}) {
MixedOneOf1? mixedOneOf1;
try {
mixedOneOf1 = serializers.deserialize(data, specifiedType: const FullType(MixedOneOf1))! as MixedOneOf1;
mixedOneOf1 = serializers.deserialize(
data,
specifiedType: const FullType(MixedOneOf1),
)! as MixedOneOf1;
} catch (_) {}
String? string;
try {
string = serializers.deserialize(data, specifiedType: const FullType(String))! as String;
string = serializers.deserialize(
data,
specifiedType: const FullType(String),
)! as String;
} catch (_) {}
return (mixedOneOf1: mixedOneOf1, string: string);
}
Expand Down Expand Up @@ -477,11 +489,17 @@ class _$b6d67dc2a96424d2f407f8e51557f3deSerializer implements PrimitiveSerialize
}) {
num? $num;
try {
$num = serializers.deserialize(data, specifiedType: const FullType(num))! as num;
$num = serializers.deserialize(
data,
specifiedType: const FullType(num),
)! as num;
} catch (_) {}
String? string;
try {
string = serializers.deserialize(data, specifiedType: const FullType(String))! as String;
string = serializers.deserialize(
data,
specifiedType: const FullType(String),
)! as String;
} catch (_) {}
return ($num: $num, string: string);
}
Expand Down Expand Up @@ -563,8 +581,10 @@ class _$00f31f9753d01398a2c3705cd335c56eSerializer implements PrimitiveSerialize
} catch (_) {}
OneOfUnspecifiedArray0? oneOfUnspecifiedArray0;
try {
oneOfUnspecifiedArray0 = serializers.deserialize(data, specifiedType: const FullType(OneOfUnspecifiedArray0))!
as OneOfUnspecifiedArray0;
oneOfUnspecifiedArray0 = serializers.deserialize(
data,
specifiedType: const FullType(OneOfUnspecifiedArray0),
)! as OneOfUnspecifiedArray0;
} catch (_) {}
return (builtListJsonObject: builtListJsonObject, oneOfUnspecifiedArray0: oneOfUnspecifiedArray0);
}
Expand Down Expand Up @@ -639,13 +659,17 @@ class _$5fb8a7f8bbb305dd61a4a05d6996c58bSerializer implements PrimitiveSerialize
}) {
BuiltList<String>? builtListString;
try {
builtListString = serializers.deserialize(data, specifiedType: const FullType(BuiltList, [FullType(String)]))!
as BuiltList<String>;
builtListString = serializers.deserialize(
data,
specifiedType: const FullType(BuiltList, [FullType(String)]),
)! as BuiltList<String>;
} catch (_) {}
OneOfStringArray0? oneOfStringArray0;
try {
oneOfStringArray0 =
serializers.deserialize(data, specifiedType: const FullType(OneOfStringArray0))! as OneOfStringArray0;
oneOfStringArray0 = serializers.deserialize(
data,
specifiedType: const FullType(OneOfStringArray0),
)! as OneOfStringArray0;
} catch (_) {}
return (builtListString: builtListString, oneOfStringArray0: oneOfStringArray0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,17 @@ class _$93403da1a64cb6a7b1597c7a05e9b2beSerializer implements PrimitiveSerialize
}) {
bool? $bool;
try {
$bool = serializers.deserialize(data, specifiedType: const FullType(bool))! as bool;
$bool = serializers.deserialize(
data,
specifiedType: const FullType(bool),
)! as bool;
} catch (_) {}
String? string;
try {
string = serializers.deserialize(data, specifiedType: const FullType(String))! as String;
string = serializers.deserialize(
data,
specifiedType: const FullType(String),
)! as String;
} catch (_) {}
return ($bool: $bool, string: string);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,17 @@ class _$b6d67dc2a96424d2f407f8e51557f3deSerializer implements PrimitiveSerialize
}) {
num? $num;
try {
$num = serializers.deserialize(data, specifiedType: const FullType(num))! as num;
$num = serializers.deserialize(
data,
specifiedType: const FullType(num),
)! as num;
} catch (_) {}
String? string;
try {
string = serializers.deserialize(data, specifiedType: const FullType(String))! as String;
string = serializers.deserialize(
data,
specifiedType: const FullType(String),
)! as String;
} catch (_) {}
return ($num: $num, string: string);
}
Expand Down
Loading

0 comments on commit a6cc324

Please sign in to comment.