diff --git a/packages/dynamite/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/dynamite/lib/src/openapi_builder.dart index 715ee969..be020277 100644 --- a/packages/dynamite/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/dynamite/lib/src/openapi_builder.dart @@ -726,7 +726,7 @@ class OpenAPIBuilder implements Builder { ), parameter.schema!, nullable: dartParameterNullable, - ); + ).dartType; state.resolvedTypeCombinations.add(result); diff --git a/packages/dynamite/dynamite/lib/src/type_result/base.dart b/packages/dynamite/dynamite/lib/src/type_result/base.dart index a0b4f297..924c98f3 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/base.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/base.dart @@ -42,4 +42,18 @@ class TypeResultBase extends TypeResult { throw Exception('Can not decode "$name" from String'); } } + + @override + TypeResultBase get dartType { + final String dartName; + switch (name) { + case 'JsonObject': + dartName = 'dynamic'; + break; + default: + dartName = name; + } + + return TypeResultBase(dartName, nullable: nullable); + } } diff --git a/packages/dynamite/dynamite/lib/src/type_result/list.dart b/packages/dynamite/dynamite/lib/src/type_result/list.dart index 5d31f9ea..944603ba 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/list.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/list.dart @@ -41,4 +41,7 @@ class TypeResultList extends TypeResult { @override String decode(final String object) => 'json.decode($object as String)'; + + @override + TypeResultList get dartType => TypeResultList('List', subType, nullable: nullable); } diff --git a/packages/dynamite/dynamite/lib/src/type_result/map.dart b/packages/dynamite/dynamite/lib/src/type_result/map.dart index 90333a41..599daeff 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/map.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/map.dart @@ -37,4 +37,7 @@ class TypeResultMap extends TypeResult { @override String decode(final String object) => 'json.decode($object as String)'; + + @override + TypeResultMap get dartType => TypeResultMap('Map', subType, nullable: nullable); } diff --git a/packages/dynamite/dynamite/lib/src/type_result/type_result.dart b/packages/dynamite/dynamite/lib/src/type_result/type_result.dart index 2807c02a..6c6b6931 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/type_result.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/type_result.dart @@ -59,4 +59,8 @@ abstract class TypeResult { }); String get nullableName => nullable ? '$name?' : name; + + /// Native dart type equivalent + // ignore: avoid_returning_this + TypeResult get dartType => this; }