diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d280450..8b9c70ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 2.3.3 + +* Fixed Issue ([#297](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/297)) +* Removed use_inheritance option. Inheritance is supported by copy-pasting parent fields + # 2.3.2 * Fixed Issue ([#290](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/290)) diff --git a/lib/src/code_generators/swagger_models_generator.dart b/lib/src/code_generators/swagger_models_generator.dart index 31a84aae..f4bfe0d0 100644 --- a/lib/src/code_generators/swagger_models_generator.dart +++ b/lib/src/code_generators/swagger_models_generator.dart @@ -1042,8 +1042,6 @@ List ${neededName.camelCase}ListFromJson( GeneratorOptions options) { final properties = getModelProperties(map, schemas); - var extendsString = options.useInheritance ? getExtendsString(map) : ''; - final generatedConstructorProperties = generateConstructorPropertiesContent( className, properties, @@ -1079,7 +1077,7 @@ List ${neededName.camelCase}ListFromJson( final generatedClass = ''' @JsonSerializable(explicitToJson: true) -class $validatedClassName $extendsString{ +class $validatedClassName { \t$validatedClassName($generatedConstructorProperties);\n \tfactory $validatedClassName.fromJson(Map json) => _\$${validatedClassName}FromJson(json);\n $generatedProperties diff --git a/lib/src/models/generator_options.dart b/lib/src/models/generator_options.dart index 1074d046..fa772383 100644 --- a/lib/src/models/generator_options.dart +++ b/lib/src/models/generator_options.dart @@ -20,7 +20,6 @@ class GeneratorOptions { this.enumsCaseSensitive = true, this.useRequiredAttributeForHeaders = true, this.usePathForRequestNames = true, - this.useInheritance = true, this.includeIfNull, this.modelPostfix = '', this.includePaths = const [], @@ -49,9 +48,6 @@ class GeneratorOptions { @JsonKey(defaultValue: false) final bool ignoreHeaders; - @JsonKey(defaultValue: true) - final bool useInheritance; - @JsonKey(defaultValue: false) final bool enumsCaseSensitive; diff --git a/lib/src/models/generator_options.g2.dart b/lib/src/models/generator_options.g2.dart index 6f4c6033..a6fbdf01 100644 --- a/lib/src/models/generator_options.g2.dart +++ b/lib/src/models/generator_options.g2.dart @@ -38,7 +38,6 @@ GeneratorOptions _$GeneratorOptionsFromJson(Map json) => GeneratorOptions( json['use_required_attribute_for_headers'] as bool? ?? true, usePathForRequestNames: json['use_path_for_request_names'] as bool? ?? true, - useInheritance: json['use_inheritance'] as bool? ?? true, includeIfNull: json['include_if_null'] as bool?, modelPostfix: json['model_postfix'] as String? ?? '', includePaths: (json['include_paths'] as List?) @@ -60,7 +59,6 @@ Map _$GeneratorOptionsToJson(GeneratorOptions instance) => 'use_required_attribute_for_headers': instance.useRequiredAttributeForHeaders, 'ignore_headers': instance.ignoreHeaders, - 'use_inheritance': instance.useInheritance, 'enums_case_sensitive': instance.enumsCaseSensitive, 'include_if_null': instance.includeIfNull, 'input_folder': instance.inputFolder, diff --git a/pubspec.yaml b/pubspec.yaml index cd0573e8..d2968714 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: swagger_dart_code_generator -version: 2.3.2 +version: 2.3.3 homepage: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator repository: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator diff --git a/test/generator_tests/models_generator_test.dart b/test/generator_tests/models_generator_test.dart index 100b4bcb..ed0387d3 100644 --- a/test/generator_tests/models_generator_test.dart +++ b/test/generator_tests/models_generator_test.dart @@ -679,27 +679,6 @@ void main() { }); }); - group('getModelInheritedProperties', () { - test('Should generate 2 levels of inheritance', () { - final result = generator.generate(model_with_inheritance, 'MyClass', - GeneratorOptions(inputFolder: '', outputFolder: '')); - - expect( - result, contains('class ExtendedErrorModel extends BasicErrorModel')); - }); - - test('Should generate 3 levels of inheritance', () { - final result = generator.generate(model_with_inheritance_3_levels, - 'MyClass', GeneratorOptions(inputFolder: '', outputFolder: '')); - - expect(result, - contains('class MostExtendedErrorModel extends ExtendedErrorModel')); - - expect( - result, contains('class ExtendedErrorModel extends BasicErrorModel')); - }); - }); - group('Tests for getValidatedClassName', () { test('Should', () { final result = SwaggerModelsGenerator.getValidatedClassName('Request');