From e13dc0a947bc1085393ab6dfd71859d39c03b768 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Mon, 31 Jul 2023 11:39:19 +0200 Subject: [PATCH 1/2] fix(dynamite): Skip comparing nullable in type results --- packages/dynamite/dynamite/lib/src/type_result/enum.dart | 8 ++------ packages/dynamite/dynamite/lib/src/type_result/list.dart | 8 ++------ packages/dynamite/dynamite/lib/src/type_result/map.dart | 8 ++------ .../dynamite/lib/src/type_result/type_result.dart | 4 ++-- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/type_result/enum.dart b/packages/dynamite/dynamite/lib/src/type_result/enum.dart index 8f2cc279..9aab53c1 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/enum.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/enum.dart @@ -34,12 +34,8 @@ class TypeResultEnum extends TypeResult { @override bool operator ==(final Object other) => - other is TypeResultEnum && - other.className == className && - other.generics == generics && - other.nullable == nullable && - other.subType == subType; + other is TypeResultEnum && other.className == className && other.generics == generics && other.subType == subType; @override - int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; + int get hashCode => className.hashCode + generics.hashCode + subType.hashCode; } diff --git a/packages/dynamite/dynamite/lib/src/type_result/list.dart b/packages/dynamite/dynamite/lib/src/type_result/list.dart index a3ce03ce..01230c91 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/list.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/list.dart @@ -34,12 +34,8 @@ class TypeResultList extends TypeResult { @override bool operator ==(final Object other) => - other is TypeResultList && - other.className == className && - other.generics == generics && - other.nullable == nullable && - other.subType == subType; + other is TypeResultList && other.className == className && other.generics == generics && other.subType == subType; @override - int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; + int get hashCode => className.hashCode + generics.hashCode + subType.hashCode; } diff --git a/packages/dynamite/dynamite/lib/src/type_result/map.dart b/packages/dynamite/dynamite/lib/src/type_result/map.dart index 7ae50130..683ff9b1 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/map.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/map.dart @@ -21,12 +21,8 @@ class TypeResultMap extends TypeResult { @override bool operator ==(final Object other) => - other is TypeResultMap && - other.className == className && - other.generics == generics && - other.nullable == nullable && - other.subType == subType; + other is TypeResultMap && other.className == className && other.generics == generics && other.subType == subType; @override - int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; + int get hashCode => className.hashCode + generics.hashCode + subType.hashCode; } 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 021b0d93..89119592 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/type_result.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/type_result.dart @@ -101,8 +101,8 @@ abstract class TypeResult { @override bool operator ==(final Object other) => - other is TypeResult && other.className == className && other.generics == generics && other.nullable == nullable; + other is TypeResult && other.className == className && other.generics == generics; @override - int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode; + int get hashCode => className.hashCode + generics.hashCode; } From b55bcdfa5c9e4daf627104b3140cc384bd0b5698 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Tue, 1 Aug 2023 09:25:50 +0200 Subject: [PATCH 2/2] refactor(dynamite): Cleanup adding resolved types --- .../dynamite/lib/src/openapi_builder.dart | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/dynamite/lib/src/openapi_builder.dart index 7a9ed929..76e4dc65 100644 --- a/packages/dynamite/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/dynamite/lib/src/openapi_builder.dart @@ -936,7 +936,11 @@ TypeResult resolveObject( final bool nullable = false, final bool isHeader = false, }) { - if (state.resolvedTypes.add(TypeResultObject('${state.prefix}$identifier'))) { + final result = TypeResultObject( + '${state.prefix}$identifier', + nullable: nullable, + ); + if (state.resolvedTypes.add(result)) { state.output.add( Class( (final b) { @@ -1230,10 +1234,7 @@ TypeResult resolveObject( ); } } - return TypeResultObject( - '${state.prefix}$identifier', - nullable: nullable, - ); + return result; } TypeResult resolveType( @@ -1263,7 +1264,11 @@ TypeResult resolveType( nullable: nullable, ); } else if (schema.ofs != null) { - if (state.resolvedTypes.add(TypeResultObject('${state.prefix}$identifier'))) { + result = TypeResultObject( + '${state.prefix}$identifier', + nullable: nullable, + ); + if (state.resolvedTypes.add(result)) { final results = schema.ofs! .map( (final s) => resolveType( @@ -1523,11 +1528,6 @@ TypeResult resolveType( ), ]); } - - result = TypeResultObject( - '${state.prefix}$identifier', - nullable: nullable, - ); } else if (schema.isContentString) { final subResult = resolveType( spec,