From ff1fe256d8a98aad3a1104d11716996dcc2e8788 Mon Sep 17 00:00:00 2001 From: rankoz <19989093+rankoz@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:18:04 +0300 Subject: [PATCH] Fix dictionary/map deserialization (#19496) --- .../serialization/json_serializable/deserialize.mustache | 8 ++++---- .../lib/src/deserialize.dart | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/deserialize.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/deserialize.mustache index edb8887328c..da750aa02b1 100644 --- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/deserialize.mustache +++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/deserialize.mustache @@ -52,13 +52,13 @@ final _regMap = RegExp(r'^Map$'); .toSet() as ReturnType; } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { - targetType = match![1]!; // ignore: parameter_assignments - return Map.fromIterables( - value.keys, + targetType = match![1]!.trim(); // ignore: parameter_assignments + return Map.fromIterables( + value.keys as Iterable, value.values.map((dynamic v) => deserialize(v, targetType, growable: growable)), ) as ReturnType; } break; - } + } throw Exception('Cannot deserialize'); } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart index 606d5e08f0d..af74c7ee5e4 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart @@ -183,13 +183,13 @@ final _regMap = RegExp(r'^Map$'); .toSet() as ReturnType; } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { - targetType = match![1]!; // ignore: parameter_assignments - return Map.fromIterables( - value.keys, + targetType = match![1]!.trim(); // ignore: parameter_assignments + return Map.fromIterables( + value.keys as Iterable, value.values.map((dynamic v) => deserialize(v, targetType, growable: growable)), ) as ReturnType; } break; - } + } throw Exception('Cannot deserialize'); } \ No newline at end of file