From 3af5f2087cc280d226537f049254abf59bd1bf74 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Fri, 5 May 2023 15:16:01 +0200 Subject: [PATCH] dynamite: split serializers Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/openapi_builder.dart | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/dynamite/lib/src/openapi_builder.dart index 3b34a890..a93d65fe 100644 --- a/packages/dynamite/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/dynamite/lib/src/openapi_builder.dart @@ -1016,11 +1016,9 @@ class OpenAPIBuilder implements Builder { '$name,', ], '])', - r'final Serializers serializers = (_$serializers.toBuilder()..addPlugin(StandardJsonPlugin())', - if (state.hasContentString) ...[ - '..addPlugin(const ContentStringPlugin())', - ], - ').build();', + r'final Serializers serializers = _$serializers;', + '', + 'final Serializers jsonSerializers = (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();', '', '// coverage:ignore-start', 'T deserialize$prefix(final Object data) => serializers.deserialize(data, specifiedType: FullType(T))! as T;', @@ -1288,14 +1286,14 @@ TypeResult resolveObject( ..type = refer('Object'), ), ) - ..body = const Code('serializers.deserializeWith(serializer, json)!'), + ..body = const Code('jsonSerializers.deserializeWith(serializer, json)!'), ), Method( (final b) => b ..name = 'toJson' ..returns = refer('Map') ..lambda = true - ..body = const Code('serializers.serializeWith(serializer, this)! as Map'), + ..body = const Code('jsonSerializers.serializeWith(serializer, this)! as Map'), ), for (final propertyName in schema.properties!.keys) ...[ Method( @@ -1501,14 +1499,14 @@ TypeResult resolveType( ..type = refer('Object'), ), ) - ..body = const Code('serializers.deserializeWith(serializer, json)!'), + ..body = const Code('jsonSerializers.deserializeWith(serializer, json)!'), ), Method( (final b) => b ..name = 'toJson' ..returns = refer('Map') ..lambda = true - ..body = const Code('serializers.serializeWith(serializer, this)! as Map'), + ..body = const Code('jsonSerializers.serializeWith(serializer, this)! as Map'), ), Method( (final b) => b