|
|
@ -65,6 +65,8 @@ class OpenAPIBuilder implements Builder { |
|
|
|
'', |
|
|
|
'', |
|
|
|
"import 'package:built_collection/built_collection.dart';", |
|
|
|
"import 'package:built_collection/built_collection.dart';", |
|
|
|
"import 'package:built_value/built_value.dart';", |
|
|
|
"import 'package:built_value/built_value.dart';", |
|
|
|
|
|
|
|
"import 'package:built_value/serializer.dart';", |
|
|
|
|
|
|
|
"import 'package:built_value/standard_json_plugin.dart';", |
|
|
|
"import 'package:cookie_jar/cookie_jar.dart';", |
|
|
|
"import 'package:cookie_jar/cookie_jar.dart';", |
|
|
|
"import 'package:universal_io/io.dart';", |
|
|
|
"import 'package:universal_io/io.dart';", |
|
|
|
'', |
|
|
|
'', |
|
|
@ -1031,24 +1033,17 @@ class OpenAPIBuilder implements Builder { |
|
|
|
|
|
|
|
|
|
|
|
if (state.registeredJsonObjects.isNotEmpty) { |
|
|
|
if (state.registeredJsonObjects.isNotEmpty) { |
|
|
|
output.addAll([ |
|
|
|
output.addAll([ |
|
|
|
'// coverage:ignore-start', |
|
|
|
'@SerializersFor(const [', |
|
|
|
'final _deserializers = <Type, dynamic Function(dynamic)>{', |
|
|
|
|
|
|
|
for (final name in state.registeredJsonObjects) ...[ |
|
|
|
for (final name in state.registeredJsonObjects) ...[ |
|
|
|
'$name: (final data) => ${TypeResultObject(name).deserialize('data')},', |
|
|
|
'$name,', |
|
|
|
'List<$name>: (final data) => ${TypeResultList('List<$name>', TypeResultObject(name)).deserialize('data')},', |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
'};', |
|
|
|
'])', |
|
|
|
|
|
|
|
r'final Serializers serializers = (_$serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();', |
|
|
|
'', |
|
|
|
'', |
|
|
|
'final _serializers = <Type, dynamic Function(dynamic)>{', |
|
|
|
'// coverage:ignore-start', |
|
|
|
for (final name in state.registeredJsonObjects) ...[ |
|
|
|
'T deserialize$prefix<T>(final Object data) => serializers.deserialize(data, specifiedType: FullType(T))! as T;', |
|
|
|
'$name: (final data) => ${TypeResultObject(name).serialize('data')},', |
|
|
|
|
|
|
|
'List<$name>: (final data) => ${TypeResultList('List<$name>', TypeResultObject(name)).serialize('data')},', |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
'};', |
|
|
|
|
|
|
|
'', |
|
|
|
|
|
|
|
'T deserialize$prefix<T>(final dynamic data) => _deserializers[T]!(data) as T;', |
|
|
|
|
|
|
|
'', |
|
|
|
'', |
|
|
|
'dynamic serialize$prefix<T>(final T data) => _serializers[T]!(data);', |
|
|
|
'Object? serialize$prefix<T>(final T data) => serializers.serialize(data, specifiedType: FullType(T));', |
|
|
|
'// coverage:ignore-end', |
|
|
|
'// coverage:ignore-end', |
|
|
|
]); |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|