Repository: epam-cross-platform-lab/swagger-dart-code-generator

Issue:
[BUG] Required values is nullable
Thank you very much for this library

**Describe the bug**
Required value in swager file is nullable when generating.

**To Reproduce**
 "BrowserInfoPostDto": {
        "required": [
          "acceptHeader",
          "colorDepth",
          "javaEnabled",
          "javascriptEnabled",
          "language",
          "timeZoneOffset",
          "userAgent"
        ],
        "type": "object",
        "properties": {
          "acceptHeader": {
            "type": "string"
          },
          "javaEnabled": {
            "type": "boolean"
          },
          "javascriptEnabled": {
            "type": "boolean"
          },
          "language": {
            "type": "string"
          },
          "colorDepth": {
            "type": "integer",
            "format": "int32"
          },
          "screenHeight": {
            "type": "integer",
            "format": "int32"
          },
          "screenWidth": {
            "type": "integer",
            "format": "int32"
          },
          "timeZoneOffset": {
            "type": "string"
          },
          "userAgent": {
            "type": "string"
          }
        },

Output
@JsonKey(name: 'acceptHeader')
  final String? acceptHeader;
  @JsonKey(name: 'javaEnabled')
  final bool? javaEnabled;
  @JsonKey(name: 'javascriptEnabled')
  final bool? javascriptEnabled;
  @JsonKey(name: 'language')
  final String? language;
  @JsonKey(name: 'colorDepth')
  final int? colorDepth;
  @JsonKey(name: 'screenHeight')
  final int? screenHeight;
  @JsonKey(name: 'screenWidth')
  final int? screenWidth;
  @JsonKey(name: 'timeZoneOffset')
  final String? timeZoneOffset;
  @JsonKey(name: 'userAgent')
  final String? userAgent;

**Expected behavior**
@JsonKey(name: 'acceptHeader')
  final String acceptHeader;
  @JsonKey(name: 'javaEnabled')
  final bool javaEnabled;
  @JsonKey(name: 'javascriptEnabled')
  final bool javascriptEnabled;
  @JsonKey(name: 'language')
  final String language;
  @JsonKey(name: 'colorDepth')
  final int colorDepth;
  @JsonKey(name: 'screenHeight')
  final int? screenHeight;
  @JsonKey(name: 'screenWidth')
  final int? screenWidth;
  @JsonKey(name: 'timeZoneOffset')
  final String timeZoneOffset;
  @JsonKey(name: 'userAgent')
  final String userAgent;

Thank you very much for your help


Discussion: Hi @mohachouch 

It's expected behaviour for this moment. We generating all required fields nullable. It's needed to have ability to use these models as request parameters, because (at least on our project) we should not send required fields sometimes.

I already have idea how to fix. We will generate separate models for Responses, and such models will have not-nullable fields
Thank you very much for your response and this wonderful work
I would suggest keeping it open to not forget to fix it when we will have two separate models fro request and responses
Hey @Vovanella95, any chance we can get the non-nullable required values (implemented vide #282)?
Hi @samarth-ramesh , I will try to implement it in a week or two

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90636230..f06435c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 2.4.7
+
+* Made required properties in models not nullable ([#324](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/324))
+* Added `nullableModels` build option to made exeptions
+
 # 2.4.6
 
 * Added authentication to `create` method ([#360](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/360))
diff --git a/example/build.yaml b/example/build.yaml
index 7c8c6ba5..981bfde9 100644
--- a/example/build.yaml
+++ b/example/build.yaml
@@ -25,7 +25,10 @@ targets:
           build_only_models: false
           separate_models: false
           enums_case_sensitive: false
-          cutFromModelNames: "V3"
+          cut_from_model_names: "V3"
+          nullable_models:
+            - "Pet"
+            - "Dog"
           ignore_headers: false
           use_required_attribute_for_headers: false
           include_if_null: false
diff --git a/example/lib/swagger_generated_code/pet_service_json.swagger.dart b/example/lib/swagger_generated_code/pet_service_json.swagger.dart
index 6ea785a4..535af4cb 100644
--- a/example/lib/swagger_generated_code/pet_service_json.swagger.dart
+++ b/example/lib/swagger_generated_code/pet_service_json.swagger.dart
@@ -22,6 +22,7 @@ part 'pet_service_json.swagger.g.dart';
 abstract class PetServiceJson extends ChopperService {
   static PetServiceJson create(
       {ChopperClient? client,
+      Authenticator? authenticator,
       String? baseUrl,
       Iterable<dynamic>? interceptors}) {
     if (client != null) {
@@ -32,6 +33,7 @@ abstract class PetServiceJson extends ChopperService {
         services: [_$PetServiceJson()],
         converter: $JsonSerializableConverter(),
         interceptors: interceptors ?? [],
+        authenticator: authenticator,
         baseUrl: baseUrl ?? 'http://petstore.swagger.io/v2');
     return _$PetServiceJson(newClient);
   }
diff --git a/example/lib/swagger_generated_code/pet_service_swagger.swagger.dart b/example/lib/swagger_generated_code/pet_service_swagger.swagger.dart
index bb465207..9ba404a1 100644
--- a/example/lib/swagger_generated_code/pet_service_swagger.swagger.dart
+++ b/example/lib/swagger_generated_code/pet_service_swagger.swagger.dart
@@ -22,6 +22,7 @@ part 'pet_service_swagger.swagger.g.dart';
 abstract class PetServiceSwagger extends ChopperService {
   static PetServiceSwagger create(
       {ChopperClient? client,
+      Authenticator? authenticator,
       String? baseUrl,
       Iterable<dynamic>? interceptors}) {
     if (client != null) {
@@ -32,6 +33,7 @@ abstract class PetServiceSwagger extends ChopperService {
         services: [_$PetServiceSwagger()],
         converter: $JsonSerializableConverter(),
         interceptors: interceptors ?? [],
+        authenticator: authenticator,
         baseUrl: baseUrl ?? 'http://petstore.swagger.io/v2');
     return _$PetServiceSwagger(newClient);
   }
diff --git a/example/lib/swagger_generated_code/pet_service_yaml.swagger.dart b/example/lib/swagger_generated_code/pet_service_yaml.swagger.dart
index 1050c2a8..5877735a 100644
--- a/example/lib/swagger_generated_code/pet_service_yaml.swagger.dart
+++ b/example/lib/swagger_generated_code/pet_service_yaml.swagger.dart
@@ -22,6 +22,7 @@ part 'pet_service_yaml.swagger.g.dart';
 abstract class PetServiceYaml extends ChopperService {
   static PetServiceYaml create(
       {ChopperClient? client,
+      Authenticator? authenticator,
       String? baseUrl,
       Iterable<dynamic>? interceptors}) {
     if (client != null) {
@@ -32,6 +33,7 @@ abstract class PetServiceYaml extends ChopperService {
         services: [_$PetServiceYaml()],
         converter: $JsonSerializableConverter(),
         interceptors: interceptors ?? [],
+        authenticator: authenticator,
         baseUrl: baseUrl ?? 'http://petstore.swagger.io/v2');
     return _$PetServiceYaml(newClient);
   }
diff --git a/lib/src/code_generators/constants.dart b/lib/src/code_generators/constants.dart
index a27d0230..31328d64 100644
--- a/lib/src/code_generators/constants.dart
+++ b/lib/src/code_generators/constants.dart
@@ -26,6 +26,7 @@ const kBasicTypes = [
 
 const kMap = 'Map';
 const kMapStringDynamic = 'Map<String,dynamic>';
+const kRequired = 'required';
 
 const kChopperService = 'ChopperService';
 const kChopperApi = 'ChopperApi';
diff --git a/lib/src/code_generators/swagger_models_generator.dart b/lib/src/code_generators/swagger_models_generator.dart
index b3d544f5..f7d4ccff 100644
--- a/lib/src/code_generators/swagger_models_generator.dart
+++ b/lib/src/code_generators/swagger_models_generator.dart
@@ -403,13 +403,15 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
   }
 
   String generatePropertyContentBySchema(
-      Map<String, dynamic> propertyEntryMap,
-      String propertyName,
-      String propertyKey,
-      String className,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      Map<String, String> basicTypesMap) {
+    Map<String, dynamic> propertyEntryMap,
+    String propertyName,
+    String propertyKey,
+    String className,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+    Map<String, String> basicTypesMap,
+    List<String> requiredProperties,
+  ) {
     final propertySchema = propertyEntryMap['schema'] as Map<String, dynamic>;
     var parameterName = propertySchema['\$ref'].toString().split('/').last;
 
@@ -440,15 +442,22 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
     final jsonKeyContent =
         "@JsonKey(name: '$propertyKey'$includeIfNullString$unknownEnumValue$dateToJsonValue)\n";
 
-    return '\t$jsonKeyContent\tfinal $typeName? ${generateFieldName(propertyName)};';
+    if (options.nullableModels.contains(className) ||
+        !requiredProperties.contains(propertyKey)) {
+      typeName = typeName.makeNullable();
+    }
+
+    return '\t$jsonKeyContent\tfinal $typeName ${generateFieldName(propertyName)};';
   }
 
   String generatePropertyContentByAllOf({
     required Map<String, dynamic> propertyEntryMap,
     required String propertyKey,
+    required String className,
     required List<String> allEnumNames,
     required List<String> allEnumListNames,
     required String propertyName,
+    required List<String> requiredProperties,
   }) {
     final allOf = propertyEntryMap['allOf'] as List;
     String typeName;
@@ -468,17 +477,24 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
     final jsonKeyContent =
         "@JsonKey(name: '$propertyKey'$includeIfNullString$unknownEnumValue)\n";
 
-    return '\t$jsonKeyContent\tfinal $typeName? $propertyName;';
+    if (options.nullableModels.contains(className) ||
+        !requiredProperties.contains(propertyKey)) {
+      typeName = typeName.makeNullable();
+    }
+
+    return '\t$jsonKeyContent\tfinal $typeName $propertyName;';
   }
 
   String generatePropertyContentByRef(
-      Map<String, dynamic> propertyEntryMap,
-      String propertyName,
-      String propertyKey,
-      String className,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      Map<String, String> basicTypesMap) {
+    Map<String, dynamic> propertyEntryMap,
+    String propertyName,
+    String propertyKey,
+    String className,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+    Map<String, String> basicTypesMap,
+    List<String> requiredProperties,
+  ) {
     final parameterName = propertyEntryMap['\$ref'].toString().split('/').last;
     String typeName;
     if (basicTypesMap.containsKey(parameterName)) {
@@ -512,14 +528,22 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
     final jsonKeyContent =
         "@JsonKey(name: '$propertyKey'$includeIfNullString$unknownEnumValue)\n";
 
-    return '\t$jsonKeyContent\tfinal $typeName? $propertyName;';
+    if (options.nullableModels.contains(className) ||
+        !requiredProperties.contains(propertyKey)) {
+      typeName = typeName.makeNullable();
+    }
+
+    return '\t$jsonKeyContent\tfinal $typeName $propertyName;';
   }
 
   String generateEnumPropertyContent(
     String key,
     String className,
+    String propertyKey,
     List<String> allEnumNames,
     List<String> allEnumListNames,
+    Map<String, dynamic> propertyEntryMap,
+    List<String> requiredProperties,
   ) {
     final enumName = getValidatedClassName(generateEnumName(className, key));
 
@@ -531,9 +555,15 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
 
     final includeIfNullString = generateIncludeIfNullString();
 
+    var enumPropertyName = className.capitalize + key.capitalize;
+    if (options.nullableModels.contains(className) ||
+        !requiredProperties.contains(propertyKey)) {
+      enumPropertyName = enumPropertyName.makeNullable();
+    }
+
     return '''
   @JsonKey($unknownEnumValue$includeIfNullString)
-  final ${className.capitalize + key.capitalize}? ${generateFieldName(key)};''';
+  final $enumPropertyName ${generateFieldName(key)};''';
   }
 
   String _generateListPropertyTypeName({
@@ -613,14 +643,16 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
   }
 
   String generateListPropertyContent(
-      String propertyName,
-      String propertyKey,
-      String className,
-      Map<String, dynamic> propertyEntryMap,
-      bool useDefaultNullForLists,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      Map<String, String> basicTypesMap) {
+    String propertyName,
+    String propertyKey,
+    String className,
+    Map<String, dynamic> propertyEntryMap,
+    bool useDefaultNullForLists,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+    Map<String, String> basicTypesMap,
+    List<String> requiredParameters,
+  ) {
     final typeName = _generateListPropertyTypeName(
       allEnumListNames: allEnumListNames,
       allEnumNames: allEnumNames,
@@ -644,7 +676,14 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
           "@JsonKey(name: '$propertyKey'$includeIfNullString$unknownEnumValue)\n";
     }
 
-    return '$jsonKeyContent  final List<$typeName>? ${generateFieldName(propertyName)};';
+    var listPropertyName = 'List<$typeName>';
+
+    if (options.nullableModels.contains(className) ||
+        !requiredParameters.contains(propertyKey)) {
+      listPropertyName = listPropertyName.makeNullable();
+    }
+
+    return '$jsonKeyContent  final $listPropertyName ${generateFieldName(propertyName)};';
   }
 
   String generateGeneralPropertyContent(
@@ -655,6 +694,7 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
     Map<String, dynamic> val,
     List<String> allEnumNames,
     List<String> allEnumListNames,
+    List<String> requiredProperties,
   ) {
     final includeIfNullString = generateIncludeIfNullString();
 
@@ -705,7 +745,8 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
       jsonKeyContent += ')\n';
     }
 
-    if (typeName != kDynamic) {
+    if (options.nullableModels.contains(className) ||
+        !requiredProperties.contains(propertyKey)) {
       typeName += '?';
     }
 
@@ -713,15 +754,17 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
   }
 
   String generatePropertyContentByType(
-      Map<String, dynamic> propertyEntryMap,
-      String propertyName,
-      String propertyKey,
-      String className,
-      List<DefaultValueMap> defaultValues,
-      bool useDefaultNullForLists,
-      List<String> allEnumsNames,
-      List<String> allEnumListNames,
-      Map<String, String> basicTypesMap) {
+    Map<String, dynamic> propertyEntryMap,
+    String propertyName,
+    String propertyKey,
+    String className,
+    List<DefaultValueMap> defaultValues,
+    bool useDefaultNullForLists,
+    List<String> allEnumsNames,
+    List<String> allEnumListNames,
+    Map<String, String> basicTypesMap,
+    List<String> requiredProperties,
+  ) {
     switch (propertyEntryMap['type'] as String) {
       case 'array':
         return generateListPropertyContent(
@@ -733,13 +776,17 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
           allEnumsNames,
           allEnumListNames,
           basicTypesMap,
+          requiredProperties,
         );
       case 'enum':
         return generateEnumPropertyContent(
           propertyName,
           className,
+          propertyKey,
           allEnumsNames,
           allEnumListNames,
+          propertyEntryMap,
+          requiredProperties,
         );
       default:
         return generateGeneralPropertyContent(
@@ -750,6 +797,7 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
           propertyEntryMap,
           allEnumsNames,
           allEnumListNames,
+          requiredProperties,
         );
     }
   }
@@ -772,6 +820,7 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
     bool useDefaultNullForLists,
     List<String> allEnumNames,
     List<String> allEnumListNames,
+    List<String> requiredProperties,
   ) {
     if (propertiesMap.isEmpty) {
       return '';
@@ -800,41 +849,51 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
 
       if (propertyEntryMap.containsKey('type')) {
         results.add(generatePropertyContentByType(
-            propertyEntryMap,
-            propertyName,
-            propertyKey,
-            className,
-            defaultValues,
-            useDefaultNullForLists,
-            allEnumNames,
-            allEnumListNames,
-            basicTypesMap));
-      } else if (propertyEntryMap['allOf'] != null) {
-        results.add(generatePropertyContentByAllOf(
-          propertyEntryMap: propertyEntryMap,
-          allEnumListNames: allEnumListNames,
-          allEnumNames: allEnumNames,
-          propertyKey: propertyKey,
-          propertyName: propertyName,
+          propertyEntryMap,
+          propertyName,
+          propertyKey,
+          className,
+          defaultValues,
+          useDefaultNullForLists,
+          allEnumNames,
+          allEnumListNames,
+          basicTypesMap,
+          requiredProperties,
         ));
+      } else if (propertyEntryMap['allOf'] != null) {
+        results.add(
+          generatePropertyContentByAllOf(
+            propertyEntryMap: propertyEntryMap,
+            allEnumListNames: allEnumListNames,
+            className: className,
+            allEnumNames: allEnumNames,
+            propertyKey: propertyKey,
+            propertyName: propertyName,
+            requiredProperties: requiredProperties,
+          ),
+        );
       } else if (propertyEntryMap['\$ref'] != null) {
         results.add(generatePropertyContentByRef(
-            propertyEntryMap,
-            propertyName,
-            propertyKey,
-            className,
-            allEnumNames,
-            allEnumListNames,
-            basicTypesMap));
+          propertyEntryMap,
+          propertyName,
+          propertyKey,
+          className,
+          allEnumNames,
+          allEnumListNames,
+          basicTypesMap,
+          requiredProperties,
+        ));
       } else if (propertyEntryMap['schema'] != null) {
         results.add(generatePropertyContentBySchema(
-            propertyEntryMap,
-            propertyName,
-            propertyKey,
-            className,
-            allEnumNames,
-            allEnumListNames,
-            basicTypesMap));
+          propertyEntryMap,
+          propertyName,
+          propertyKey,
+          className,
+          allEnumNames,
+          allEnumListNames,
+          basicTypesMap,
+          requiredProperties,
+        ));
       } else {
         results.add(generatePropertyContentByDefault(
           propertyEntryMap,
@@ -982,13 +1041,14 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
     ''';
   }
 
-  String generateConstructorPropertiesContent(
-    String className,
-    Map<String, dynamic> entityMap,
-    List<DefaultValueMap> defaultValues,
-    List<String> allEnumNames,
-    List<String> allEnumListNames,
-  ) {
+  String generateConstructorPropertiesContent({
+    required String className,
+    required Map<String, dynamic> entityMap,
+    required List<DefaultValueMap> defaultValues,
+    required List<String> requiredProperties,
+    required List<String> allEnumNames,
+    required List<String> allEnumListNames,
+  }) {
     if (entityMap.isEmpty) {
       return '';
     }
@@ -1001,7 +1061,12 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
 
       propertyNames.add(fieldName);
 
-      results += '\t\tthis.$fieldName,\n';
+      if (options.nullableModels.contains(className) ||
+          !requiredProperties.contains(key)) {
+        results += '\t\tthis.$fieldName,\n';
+      } else {
+        results += '\t\t$kRequired this.$fieldName,\n';
+      }
     });
 
     return '{\n$results\n\t}';
@@ -1018,13 +1083,16 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
     List<String> allEnumListNames,
   ) {
     final properties = getModelProperties(map, schemas);
+    final requiredProperties =
+        (map[kRequired] as List? ?? const []).cast<String>();
 
     final generatedConstructorProperties = generateConstructorPropertiesContent(
-      className,
-      properties,
-      defaultValues,
-      allEnumNames,
-      allEnumListNames,
+      className: className,
+      entityMap: properties,
+      defaultValues: defaultValues,
+      allEnumNames: allEnumNames,
+      allEnumListNames: allEnumListNames,
+      requiredProperties: requiredProperties,
     );
 
     final generatedProperties = generatePropertiesContent(
@@ -1036,6 +1104,7 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
       useDefaultNullForLists,
       allEnumNames,
       allEnumListNames,
+      requiredProperties,
     );
 
     final validatedClassName =
diff --git a/lib/src/models/generator_options.dart b/lib/src/models/generator_options.dart
index 62afb851..13c537e9 100644
--- a/lib/src/models/generator_options.dart
+++ b/lib/src/models/generator_options.dart
@@ -25,6 +25,7 @@ class GeneratorOptions {
     this.includePaths = const [],
     this.excludePaths = const [],
     this.inputUrls = const [],
+    this.nullableModels = const [],
     this.cutFromModelNames = '',
   });
 
@@ -44,6 +45,9 @@ class GeneratorOptions {
   @JsonKey(defaultValue: [])
   List<String> inputUrls;
 
+  @JsonKey(defaultValue: [])
+  List<String> nullableModels;
+
   @JsonKey(defaultValue: false)
   final bool separateModels;
 
diff --git a/lib/src/models/generator_options.g2.dart b/lib/src/models/generator_options.g2.dart
index b41d9b6d..f936df06 100644
--- a/lib/src/models/generator_options.g2.dart
+++ b/lib/src/models/generator_options.g2.dart
@@ -52,6 +52,10 @@ GeneratorOptions _$GeneratorOptionsFromJson(Map json) => GeneratorOptions(
               ?.map((e) => e as String)
               .toList() ??
           [],
+      nullableModels: (json['nullable_models'] as List<dynamic>?)
+              ?.map((e) => e as String)
+              .toList() ??
+          [],
       cutFromModelNames: json['cut_from_model_names'] as String? ?? '',
     );
 
@@ -61,6 +65,7 @@ Map<String, dynamic> _$GeneratorOptionsToJson(GeneratorOptions instance) =>
       'with_base_url': instance.withBaseUrl,
       'with_converter': instance.withConverter,
       'input_urls': instance.inputUrls,
+      'nullable_models': instance.nullableModels,
       'separate_models': instance.separateModels,
       'use_required_attribute_for_headers':
           instance.useRequiredAttributeForHeaders,
diff --git a/pubspec.yaml b/pubspec.yaml
index 239c5fa3..f46e9b57 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
 name: swagger_dart_code_generator
 
-version: 2.4.6
+version: 2.4.7
 
 homepage: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator
 repository: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator


Test patch:
diff --git a/test/generator_tests/models_generator_test.dart b/test/generator_tests/models_generator_test.dart
index 6a7a79a3..589c76d4 100644
--- a/test/generator_tests/models_generator_test.dart
+++ b/test/generator_tests/models_generator_test.dart
@@ -58,7 +58,7 @@ void main() {
       expect(
           result,
           contains(
-              'final enums.ActiveOrderAndListSummaryShoppingType? shoppingType'));
+              'final enums.ActiveOrderAndListSummaryShoppingType shoppingType'));
     });
 
     test('Should parse object name as a field Type', () {
@@ -282,6 +282,7 @@ void main() {
         [],
         [],
         {},
+        [],
       );
 
       expect(result, contains(jsonKeyExpendedResult));
@@ -302,6 +303,7 @@ void main() {
         ['enums.Pet'],
         [],
         {},
+        [],
       );
 
       expect(result, contains('toJson: petToJson, fromJson: petFromJson'));
@@ -319,8 +321,11 @@ void main() {
       final result = generator.generateEnumPropertyContent(
         key,
         className,
+        key,
         [],
         [],
+        {},
+        [],
       );
 
       expect(result, contains(jsonKeyExpectedResult));
@@ -378,11 +383,12 @@ void main() {
     test('Should return empty', () {
       const expectedResult = '';
       final result = generator.generateConstructorPropertiesContent(
-        '',
-        {},
-        [],
-        [],
-        [],
+        className: '',
+        entityMap: {},
+        defaultValues: [],
+        requiredProperties: [],
+        allEnumNames: [],
+        allEnumListNames: [],
       );
 
       expect(result, contains(expectedResult));
@@ -394,11 +400,12 @@ void main() {
       };
       const expectedResult = 'this.animal';
       final result = generator.generateConstructorPropertiesContent(
-        '',
-        map,
-        [],
-        [],
-        [],
+        className: '',
+        entityMap: map,
+        defaultValues: [],
+        requiredProperties: [],
+        allEnumNames: [],
+        allEnumListNames: [],
       );
 
       expect(result, contains(expectedResult));
@@ -423,6 +430,7 @@ void main() {
         [],
         [],
         {},
+        [],
       );
 
       expect(result, contains(jsonKeyExpectedResult));
@@ -445,6 +453,7 @@ void main() {
         ['enums.Pet'],
         [],
         {},
+        [],
       );
 
       expect(result, contains('toJson: petToJson, fromJson: petFromJson'));
@@ -469,6 +478,7 @@ void main() {
         false,
         [],
         [],
+        [],
       );
 
       expect(result, contains(jsonKeyExpectedResult));
@@ -494,6 +504,7 @@ void main() {
         false,
         [],
         [],
+        [],
       );
 
       expect(result, contains(jsonKeyExpectedResult));
@@ -517,6 +528,7 @@ void main() {
         false,
         [],
         [],
+        [],
       );
 
       expect(result, contains(jsonKeyExpectedResult));
@@ -540,6 +552,7 @@ void main() {
         false,
         [],
         [],
+        [],
       );
 
       expect(result, contains(jsonKeyExpectedResult));
@@ -566,6 +579,7 @@ void main() {
         [],
         [],
         {},
+        [],
       );
 
       expect(result, contains(jsonKeyExpectedResult));
@@ -588,6 +602,7 @@ void main() {
         ['Dog'],
         [],
         {},
+        [],
       );
 
       expect(
@@ -611,6 +626,7 @@ void main() {
         [],
         [],
         {},
+        [],
       );
 
       expect(result, contains('final List<TestOriginalRef>? dog;'));
@@ -633,6 +649,7 @@ void main() {
         [],
         [],
         {},
+        [],
       );
 
       expect(result, contains('final List<TestObject>? dog;'));
@@ -655,6 +672,7 @@ void main() {
         [],
         [],
         {},
+        [],
       );
 
       expect(result,
@@ -677,6 +695,7 @@ void main() {
         [],
         [],
         {},
+        [],
       );
 
       expect(result, contains('final List<Object>? dog;'));
@@ -701,6 +720,7 @@ void main() {
         {'\$ref': 'ClassNameName'},
         ['enums.ClassNameName'],
         [],
+        [],
       );
 
       expect(result, contains('final enums.ClassNameName? name;'));