Browse Source

Merge pull request #519 from provokateurin/fix/dynamite-duplicate-types

fix(dynamite): Skip comparing nullable in type results
pull/521/head
Kate 1 year ago committed by GitHub
parent
commit
45c8117104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      packages/dynamite/dynamite/lib/src/openapi_builder.dart
  2. 8
      packages/dynamite/dynamite/lib/src/type_result/enum.dart
  3. 8
      packages/dynamite/dynamite/lib/src/type_result/list.dart
  4. 8
      packages/dynamite/dynamite/lib/src/type_result/map.dart
  5. 4
      packages/dynamite/dynamite/lib/src/type_result/type_result.dart

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

@ -936,7 +936,11 @@ TypeResult resolveObject(
final bool nullable = false, final bool nullable = false,
final bool isHeader = 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( state.output.add(
Class( Class(
(final b) { (final b) {
@ -1230,10 +1234,7 @@ TypeResult resolveObject(
); );
} }
} }
return TypeResultObject( return result;
'${state.prefix}$identifier',
nullable: nullable,
);
} }
TypeResult resolveType( TypeResult resolveType(
@ -1263,7 +1264,11 @@ TypeResult resolveType(
nullable: nullable, nullable: nullable,
); );
} else if (schema.ofs != null) { } 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! final results = schema.ofs!
.map( .map(
(final s) => resolveType( (final s) => resolveType(
@ -1523,11 +1528,6 @@ TypeResult resolveType(
), ),
]); ]);
} }
result = TypeResultObject(
'${state.prefix}$identifier',
nullable: nullable,
);
} else if (schema.isContentString) { } else if (schema.isContentString) {
final subResult = resolveType( final subResult = resolveType(
spec, spec,

8
packages/dynamite/dynamite/lib/src/type_result/enum.dart

@ -34,12 +34,8 @@ class TypeResultEnum extends TypeResult {
@override @override
bool operator ==(final Object other) => bool operator ==(final Object other) =>
other is TypeResultEnum && other is TypeResultEnum && other.className == className && other.generics == generics && other.subType == subType;
other.className == className &&
other.generics == generics &&
other.nullable == nullable &&
other.subType == subType;
@override @override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; int get hashCode => className.hashCode + generics.hashCode + subType.hashCode;
} }

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

@ -34,12 +34,8 @@ class TypeResultList extends TypeResult {
@override @override
bool operator ==(final Object other) => bool operator ==(final Object other) =>
other is TypeResultList && other is TypeResultList && other.className == className && other.generics == generics && other.subType == subType;
other.className == className &&
other.generics == generics &&
other.nullable == nullable &&
other.subType == subType;
@override @override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; int get hashCode => className.hashCode + generics.hashCode + subType.hashCode;
} }

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

@ -21,12 +21,8 @@ class TypeResultMap extends TypeResult {
@override @override
bool operator ==(final Object other) => bool operator ==(final Object other) =>
other is TypeResultMap && other is TypeResultMap && other.className == className && other.generics == generics && other.subType == subType;
other.className == className &&
other.generics == generics &&
other.nullable == nullable &&
other.subType == subType;
@override @override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; int get hashCode => className.hashCode + generics.hashCode + subType.hashCode;
} }

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

@ -101,8 +101,8 @@ abstract class TypeResult {
@override @override
bool operator ==(final Object other) => 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 @override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode; int get hashCode => className.hashCode + generics.hashCode;
} }

Loading…
Cancel
Save