Browse Source

dynamite: use dart types as parameters

pull/324/head
Nikolas Rimikis 2 years ago
parent
commit
e6314be5c0
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/dynamite/dynamite/lib/src/openapi_builder.dart
  2. 14
      packages/dynamite/dynamite/lib/src/type_result/base.dart
  3. 3
      packages/dynamite/dynamite/lib/src/type_result/list.dart
  4. 3
      packages/dynamite/dynamite/lib/src/type_result/map.dart
  5. 4
      packages/dynamite/dynamite/lib/src/type_result/type_result.dart

2
packages/dynamite/dynamite/lib/src/openapi_builder.dart

@ -726,7 +726,7 @@ class OpenAPIBuilder implements Builder {
), ),
parameter.schema!, parameter.schema!,
nullable: dartParameterNullable, nullable: dartParameterNullable,
); ).dartType;
state.resolvedTypeCombinations.add(result); state.resolvedTypeCombinations.add(result);

14
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'); 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);
}
} }

3
packages/dynamite/dynamite/lib/src/type_result/list.dart

@ -41,4 +41,7 @@ class TypeResultList extends TypeResult {
@override @override
String decode(final String object) => 'json.decode($object as String)'; String decode(final String object) => 'json.decode($object as String)';
@override
TypeResultList get dartType => TypeResultList('List', subType, nullable: nullable);
} }

3
packages/dynamite/dynamite/lib/src/type_result/map.dart

@ -37,4 +37,7 @@ class TypeResultMap extends TypeResult {
@override @override
String decode(final String object) => 'json.decode($object as String)'; String decode(final String object) => 'json.decode($object as String)';
@override
TypeResultMap get dartType => TypeResultMap('Map', subType, nullable: nullable);
} }

4
packages/dynamite/dynamite/lib/src/type_result/type_result.dart

@ -59,4 +59,8 @@ abstract class TypeResult {
}); });
String get nullableName => nullable ? '$name?' : name; String get nullableName => nullable ? '$name?' : name;
/// Native dart type equivalent
// ignore: avoid_returning_this
TypeResult get dartType => this;
} }

Loading…
Cancel
Save