Browse Source

Merge pull request #370 from Leptopoda/fix/#367

Fix/#367 dynamite:duplicate builderFactories
pull/376/head
Nikolas Rimikis 2 years ago committed by GitHub
parent
commit
6b60409912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/dynamite/dynamite/lib/dynamite.dart
  2. 6
      packages/dynamite/dynamite/lib/src/openapi_builder.dart
  3. 3
      packages/dynamite/dynamite/lib/src/type_result/base.dart
  4. 14
      packages/dynamite/dynamite/lib/src/type_result/enum.dart
  5. 14
      packages/dynamite/dynamite/lib/src/type_result/list.dart
  6. 14
      packages/dynamite/dynamite/lib/src/type_result/map.dart
  7. 3
      packages/dynamite/dynamite/lib/src/type_result/object.dart
  8. 17
      packages/dynamite/dynamite/lib/src/type_result/type_result.dart
  9. 1
      packages/dynamite/dynamite/pubspec.yaml
  10. 2
      packages/dynamite/dynamite/test/type_result_test.dart
  11. 11
      packages/nextcloud/lib/src/nextcloud.openapi.dart

8
packages/dynamite/dynamite/lib/dynamite.dart

@ -9,13 +9,7 @@ import 'package:dynamite/src/models/open_api.dart';
import 'package:dynamite/src/models/parameter.dart' as spec_parameter;
import 'package:dynamite/src/models/path_item.dart';
import 'package:dynamite/src/models/schema.dart';
import 'package:intersperse/intersperse.dart';
import 'package:dynamite/src/type_result/type_result.dart';
import 'package:path/path.dart' as p;
part 'src/openapi_builder.dart';
part 'src/type_result/base.dart';
part 'src/type_result/enum.dart';
part 'src/type_result/list.dart';
part 'src/type_result/map.dart';
part 'src/type_result/object.dart';
part 'src/type_result/type_result.dart';

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

@ -1228,10 +1228,10 @@ class State {
State(this.prefix);
final String prefix;
final resolvedTypes = <String>[];
final registeredJsonObjects = <String>[];
final resolvedTypes = <String>{};
final registeredJsonObjects = <String>{};
final output = <Spec>[];
final resolvedTypeCombinations = <TypeResult>[];
final resolvedTypeCombinations = <TypeResult>{};
}
TypeResult resolveObject(

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

@ -1,5 +1,6 @@
part of '../../dynamite.dart';
part of 'type_result.dart';
@immutable
class TypeResultBase extends TypeResult {
TypeResultBase(
super.name, {

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

@ -1,5 +1,6 @@
part of '../../dynamite.dart';
part of 'type_result.dart';
@immutable
class TypeResultEnum extends TypeResult {
TypeResultEnum(
super.name,
@ -27,4 +28,15 @@ class TypeResultEnum extends TypeResult {
@override
String decode(final String object) => subType.decode(object);
@override
bool operator ==(final Object other) =>
other is TypeResultEnum &&
other.className == className &&
other.generics == generics &&
other.nullable == nullable &&
other.subType == subType;
@override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode;
}

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

@ -1,5 +1,6 @@
part of '../../dynamite.dart';
part of 'type_result.dart';
@immutable
class TypeResultList extends TypeResult {
TypeResultList(
super.name,
@ -27,4 +28,15 @@ class TypeResultList extends TypeResult {
@override
TypeResultList get dartType => TypeResultList('List', subType, nullable: nullable);
@override
bool operator ==(final Object other) =>
other is TypeResultList &&
other.className == className &&
other.generics == generics &&
other.nullable == nullable &&
other.subType == subType;
@override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode;
}

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

@ -1,5 +1,6 @@
part of '../../dynamite.dart';
part of 'type_result.dart';
@immutable
class TypeResultMap extends TypeResult {
TypeResultMap(
super.name,
@ -14,4 +15,15 @@ class TypeResultMap extends TypeResult {
@override
TypeResultMap get dartType => TypeResultMap('Map', subType, nullable: nullable);
@override
bool operator ==(final Object other) =>
other is TypeResultMap &&
other.className == className &&
other.generics == generics &&
other.nullable == nullable &&
other.subType == subType;
@override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode;
}

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

@ -1,7 +1,8 @@
part of '../../dynamite.dart';
part of 'type_result.dart';
const _contentString = 'ContentString';
@immutable
class TypeResultObject extends TypeResult {
TypeResultObject(
super.className, {

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

@ -1,5 +1,13 @@
part of '../../dynamite.dart';
import 'package:intersperse/intersperse.dart';
import 'package:meta/meta.dart';
part 'base.dart';
part 'enum.dart';
part 'list.dart';
part 'map.dart';
part 'object.dart';
@immutable
abstract class TypeResult {
TypeResult(
this.className, {
@ -84,4 +92,11 @@ abstract class TypeResult {
/// Native dart type equivalent
// ignore: avoid_returning_this
TypeResult get dartType => this;
@override
bool operator ==(final Object other) =>
other is TypeResult && other.className == className && other.generics == generics && other.nullable == nullable;
@override
int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode;
}

1
packages/dynamite/dynamite/pubspec.yaml

@ -11,6 +11,7 @@ dependencies:
dart_style: ^2.3.1
intersperse: ^2.0.0
json_annotation: ^4.8.1
meta: ^1.9.1
path: ^1.8.3
dev_dependencies:

2
packages/dynamite/dynamite/test/type_result_test.dart

@ -1,4 +1,4 @@
import 'package:dynamite/dynamite.dart';
import 'package:dynamite/src/type_result/type_result.dart';
import 'package:test/test.dart';
void main() {

11
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -5182,20 +5182,14 @@ final Serializers serializers = (_$serializers.toBuilder()
..addBuilderFactory(const FullType(NextcloudCoreAutocompleteResult), NextcloudCoreAutocompleteResult.new)
..addBuilderFactory(const FullType(NextcloudNewsSupportedAPIVersions), NextcloudNewsSupportedAPIVersions.new)
..addBuilderFactory(const FullType(NextcloudNewsListFolders), NextcloudNewsListFolders.new)
..addBuilderFactory(const FullType(NextcloudNewsListFolders), NextcloudNewsListFolders.new)
..addBuilderFactory(const FullType(NextcloudNewsListFeeds), NextcloudNewsListFeeds.new)
..addBuilderFactory(const FullType(NextcloudNewsListFeeds), NextcloudNewsListFeeds.new)
..addBuilderFactory(const FullType(NextcloudNewsListArticles), NextcloudNewsListArticles.new)
..addBuilderFactory(const FullType(NextcloudNewsListArticles), NextcloudNewsListArticles.new)
..addBuilderFactory(const FullType(NextcloudNotesNote), NextcloudNotesNote.new)
..addBuilderFactory(
const FullType(BuiltList, [FullType(NextcloudNotesNote)]),
ListBuilder<NextcloudNotesNote>.new,
)
..addBuilderFactory(const FullType(NextcloudNotesNote), NextcloudNotesNote.new)
..addBuilderFactory(const FullType(NextcloudNotesNote), NextcloudNotesNote.new)
..addBuilderFactory(const FullType(NextcloudNotesNote), NextcloudNotesNote.new)
..addBuilderFactory(const FullType(NextcloudNotesSettings), NextcloudNotesSettings.new)
..addBuilderFactory(const FullType(NextcloudNotesSettings), NextcloudNotesSettings.new)
..addBuilderFactory(
const FullType(NextcloudNotificationsListNotifications),
@ -5210,8 +5204,6 @@ final Serializers serializers = (_$serializers.toBuilder()
const FullType(NextcloudNotificationsPushServerRegistration),
NextcloudNotificationsPushServerRegistration.new,
)
..addBuilderFactory(const FullType(NextcloudEmptyOCS), NextcloudEmptyOCS.new)
..addBuilderFactory(const FullType(NextcloudProvisioningApiUser), NextcloudProvisioningApiUser.new)
..addBuilderFactory(const FullType(NextcloudProvisioningApiUser), NextcloudProvisioningApiUser.new)
..addBuilderFactory(
const FullType(NextcloudUnifiedPushProviderCheckResponse200ApplicationJson),
@ -5263,9 +5255,6 @@ final Serializers serializers = (_$serializers.toBuilder()
)
..addBuilderFactory(const FullType(NextcloudUserStatusGetPublicStatus), NextcloudUserStatusGetPublicStatus.new)
..addBuilderFactory(const FullType(NextcloudUserStatusGetStatus), NextcloudUserStatusGetStatus.new)
..addBuilderFactory(const FullType(NextcloudUserStatusGetStatus), NextcloudUserStatusGetStatus.new)
..addBuilderFactory(const FullType(NextcloudUserStatusGetStatus), NextcloudUserStatusGetStatus.new)
..addBuilderFactory(const FullType(NextcloudUserStatusGetStatus), NextcloudUserStatusGetStatus.new)
..addBuilderFactory(
const FullType(NextcloudUserStatusPredefinedStatuses),
NextcloudUserStatusPredefinedStatuses.new,

Loading…
Cancel
Save