From 23c8897769f3c4602c70bb0fa3ec235e378142ea Mon Sep 17 00:00:00 2001 From: Wahab Alshahin Date: Thu, 3 Aug 2023 13:39:26 -0400 Subject: [PATCH] Convert union classes to sealed --- CHANGELOG.md | 5 +++++ lib/src/generators/schema.dart | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2faf15b..d13ad88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.4.5 + +* Convert union types to sealed classes +* Make union constructors public + ## 0.4.4 * Reduce collection package version requirement diff --git a/lib/src/generators/schema.dart b/lib/src/generators/schema.dart index 46c3d88..1f9e866 100644 --- a/lib/src/generators/schema.dart +++ b/lib/src/generators/schema.dart @@ -173,7 +173,7 @@ class SchemaGenerator extends BaseGenerator { /// Union class for ${schemas.map((e) => '[$e]').join(', ')} @Freezed(unionKey: '$unionKey') - class $union with _\$$union { + sealed class $union with _\$$union { const $union._();\n """, mode: FileMode.append); @@ -240,7 +240,7 @@ class SchemaGenerator extends BaseGenerator { } /// Class Footer - file.writeAsStringSync("}) = _$union$uSubClass;\n\n", + file.writeAsStringSync("}) = $union$uSubClass;\n\n", mode: FileMode.append); } diff --git a/pubspec.yaml b/pubspec.yaml index b08c94f..2fd898c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: openapi_spec description: OpenAPI Specification generator using native Dart code, as well as an all-in-one parser of existing specifications. -version: 0.4.4 +version: 0.4.5 maintainer: Taza Technology LLC repository: https://github.com/tazatechnology/openapi_spec issue_tracker: https://github.com/tazatechnology/openapi_spec/issues