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

Issue:
[BUG] No output to defined result paths in `v2.4.3`, ok in `v2.4.2`.
**Describe the bug**
When building with `flutter pub run build_runner build --delete-conflicting-outputs` with `v2.4.3` there are no files generated in my result path defined in the `build.yaml` file. 

**To Reproduce**
Here is the `pubspec.yaml` content:
```
name: m_work_admin
description: mWork admin module.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.16.0-134.5.beta <3.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter

  # ---flutter settings screen
  flutter_settings_screens: ^0.3.2-null-safety

  # ---Microsoft Client Access
  msal_js: ^2.14.0

  # ---Bidirectional listview
  bidirectional_listview: ^1.0.3
  infinite_listview: ^1.1.0

  # ---Swagger changes
  chopper: ^4.0.5
  json_annotation: ^4.4.0

  #---linked_scroll_controller
  linked_scroll_controller: ^0.2.0

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter

  # ---Swagger changes
  build_runner: ^2.1.7
  chopper_generator: ^4.0.5
  json_serializable: ^6.1.4
  swagger_dart_code_generator: 2.4.2

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^1.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

```
Here is the `build.yaml` content

```
targets:
  $default:
    sources:
      - swaggers/**
      - lib/**
      - $package$
    builders:
      chopper_generator:
        options:
          header: "//Generated code"
      swagger_dart_code_generator:
        options:
          input_folder: "swaggers/"
          output_folder: "lib/services/api/generated"
```

And here's the swagger file used (as a `.txt` file when github prohibits upload of rich content files):

[m_work_admin_api.swagger.txt](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/files/8177267/m_work_admin_api.swagger.txt)


**Expected behavior**
The files should be generated in the specified path in the `build.yaml` file.

**Remedy**
Use `v2.4.2` or lower...

**Flutter doctor --verbose**
```
C:\Flutter\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel beta, 2.11.0-0.1.pre, on Microsoft Windows [Version 10.0.22000.493], locale nb-NO)
    • Flutter version 2.11.0-0.1.pre at C:\Flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b101bfe32f (2 weeks ago), 2022-02-16 07:36:54 -0800
    • Engine revision e355993572
    • Dart version 2.17.0 (build 2.17.0-69.2.beta)
    • DevTools version 2.10.0-dev.1

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at C:\Users\RoarGronmo\AppData\Local\Android\sdk
    • Platform android-Tiramisu, build-tools 32.1.0-rc1
    • Java binary at: C:\Program Files\Android Studio\Android Studio 2021.3.1.3\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.3)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31702.278
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android Studio\Android Studio 2020.3.1.26
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] Android Studio (version 2021.1)
    • Android Studio at C:\Program Files\Android Studio\Android Studio 2021.1.1.22
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[√] Android Studio (version 2021.1)
    • Android Studio at C:\Program Files\Android Studio\Android Studio 2021.1.1.1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android Studio\Android Studio 2021.2.1.9
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android Studio\Android Studio 2021.3.1.3
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22000.493]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 98.0.4758.102
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 98.0.1108.43

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
Process finished with exit code 0
```
Chopper Authenticator Implementation
**Is your feature request related to a problem? Please describe.**
When initializing the api, i would like to pass a chopper Authenticator.

**Describe the solution you'd like**
For things like token-refresh, I need to use the Authenticator class instead of the interceptorts, to be able to retry the request with new tokens. You could pass these optionally in the constructor like you do with the interceptors.

Thank you very much, this project helps me a lot!



[QUESTION] Need option to shorten model names
Now we have long model names on the project after generation. Is there a way to shorten them? 
Maybe in the settings specify a prefix that will be deleted?

![image](https://user-images.githubusercontent.com/18750948/159700417-d004bf90-3c5e-4e3a-98a9-7de4851b5587.png)




Discussion: Hi @RoarGronmo I have tried your build.yaml file and your swagger file on my PC and everything is generated. Possible problem happens only on Windows. I will check it today evening on my Windows PC.
I also had problems with the generation today. On Mac (M1, latest OS) I get the following error:

    FileSystemException: Cannot create file, path = 'lib/ui' (OS Error: Is a directory, errno = 21)
    dart:io                                                                     _File.createSync
    package:swagger_dart_code_generator/swagger_dart_code_generator.dart 60:30  _generateExtensions
    package:swagger_dart_code_generator/swagger_dart_code_generator.dart 98:32  SwaggerDartCodeGenerator.buildExtensions
    package:build_runner_core/src/package_graph/apply_builders.dart 403:33      _validateBuilder
    package:build_runner_core/src/package_graph/apply_builders.dart 183:9       new BuilderApplication.forBuilder.<fn>.<fn>
    package:build_runner_core/src/package_graph/apply_builders.dart 346:27      _createBuildPhasesForBuilderInCycle.<fn>.<fn>
    dart:core                                                                   Iterable.toList
    package:build_runner_core/src/package_graph/apply_builders.dart 293:8       createBuildPhases
    package:build_runner_core/src/generate/build_impl.dart 109:29               BuildImpl.create
    package:build_runner_core/src/generate/build_runner.dart 34:42              BuildRunner.create
    package:build_runner/src/generate/build.dart 109:35                         build
    package:build_runner/src/entrypoint/build.dart 35:18                        BuildCommand._run
    package:args/command_runner.dart 209:13                                     CommandRunner.runCommand
    package:build_runner/src/entrypoint/run.dart 26:18                          run
    .dart_tool/build/entrypoint/build.dart 38:16                                main

Yes, I have a `lib/ui` folder in my code, and I don't see why that could be a problem. Deleting it is not an option, there are too many dependencies. I can't reproduce the error using the example project, even if I create an empty `lib/ui` folder.

On Windows, nothing gets generated and no errors occur.

This message is not a complete bug report or question, I still need time to investigate and I'll open a new issue if I find something more reproducible.
BTW as comment to @dJani97 : I do not have any `lib/ui` path in my project, so I don't think this error is related to that. You should maybe file another issue for your particular problem. (I`m in Windows 11).


@Vovanella95 please change following line in `pubspec.yaml` file:
```
swagger_dart_code_generator: 2.4.2
```
to
```
swagger_dart_code_generator: ^2.4.3
```

Sorry, I didn't realize that I sent you the contents where it worked, and not the contents where it didn't work.

I had to pin the `swagger_dart_code_generator` to version `2.4.2` to get it to generate code. 
@RoarGronmo  yes I understand I should check it on latest version. There I've rid of not needed temp file. I will check it on my Windows machine, I hope problem in it.
Did you check it out ? I can't see any update for this particular problem...
Hi @RoarGronmo , sorry I had long weekends in my country :D I will check it today evening. Sorry for this delay
Long weekends are important for your brilliant minds !!



Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c4c28b6..90636230 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 2.4.6
+
+* Added authentication to `create` method ([#360](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/360))
+* Added ability to refactor model names ([#361](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/361))
+
 # 2.4.5
 
 * Fixed generation on Windows ([#354](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/354))
diff --git a/example/build.yaml b/example/build.yaml
index 9e1bc848..7c8c6ba5 100644
--- a/example/build.yaml
+++ b/example/build.yaml
@@ -25,6 +25,7 @@ targets:
           build_only_models: false
           separate_models: false
           enums_case_sensitive: false
+          cutFromModelNames: "V3"
           ignore_headers: false
           use_required_attribute_for_headers: false
           include_if_null: false
diff --git a/lib/src/code_generators/swagger_additions_generator.dart b/lib/src/code_generators/swagger_additions_generator.dart
index faffa23b..58377261 100644
--- a/lib/src/code_generators/swagger_additions_generator.dart
+++ b/lib/src/code_generators/swagger_additions_generator.dart
@@ -1,8 +1,16 @@
+import 'package:swagger_dart_code_generator/src/code_generators/swagger_generator_base.dart';
 import 'package:swagger_dart_code_generator/src/extensions/file_name_extensions.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 
 ///Generates index file content, converter and additional methods
-class SwaggerAdditionsGenerator {
+class SwaggerAdditionsGenerator extends SwaggerGeneratorBase {
+  final GeneratorOptions _options;
+
+  @override
+  GeneratorOptions get options => _options;
+
+  SwaggerAdditionsGenerator(this._options);
+
   static const mappingVariableName = 'generatedMapping';
 
   ///Generates index.dart for all generated services
@@ -116,8 +124,7 @@ String? _dateToJson(DateTime? date) {
   }
 
   ///Copy-pasted converter from internet
-  String generateCustomJsonConverter(
-      String fileName, GeneratorOptions options) {
+  String generateCustomJsonConverter(String fileName) {
     if (!options.withConverter) {
       return '';
     }
@@ -176,33 +183,4 @@ class \$JsonSerializableConverter extends chopper.JsonConverter {
 final \$jsonDecoder = \$CustomJsonDecoder(generatedMapping);
     ''';
   }
-
-  static String getChopperClientContent(
-    String className,
-    String host,
-    String basePath,
-    GeneratorOptions options,
-  ) {
-    final baseUrlString = options.withBaseUrl
-        ? "baseUrl:  baseUrl ?? 'http://$host$basePath'"
-        : '/*baseUrl: YOUR_BASE_URL*/';
-
-    final converterString = options.withConverter
-        ? 'converter: \$JsonSerializableConverter(),'
-        : 'converter: chopper.JsonConverter(),';
-
-    final chopperClientBody = '''
-    if(client!=null){
-      return _\$$className(client);
-    }
-
-    final newClient = ChopperClient(
-      services: [_\$$className()],
-      $converterString
-      interceptors: interceptors ?? [],
-      $baseUrlString);
-    return _\$$className(newClient);
-''';
-    return chopperClientBody;
-  }
 }
diff --git a/lib/src/code_generators/swagger_enums_generator.dart b/lib/src/code_generators/swagger_enums_generator.dart
index 69194d36..aef084dc 100644
--- a/lib/src/code_generators/swagger_enums_generator.dart
+++ b/lib/src/code_generators/swagger_enums_generator.dart
@@ -1,18 +1,26 @@
 import 'package:recase/recase.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/constants.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_models_generator.dart';
+import 'package:swagger_dart_code_generator/src/code_generators/swagger_generator_base.dart';
 import 'package:swagger_dart_code_generator/src/exception_words.dart';
 import 'package:swagger_dart_code_generator/src/extensions/string_extension.dart';
+import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 import 'package:swagger_dart_code_generator/src/swagger_models/requests/swagger_request.dart';
 import 'package:swagger_dart_code_generator/src/swagger_models/requests/swagger_request_parameter.dart';
 import 'package:swagger_dart_code_generator/src/swagger_models/swagger_path.dart';
 import 'package:swagger_dart_code_generator/src/swagger_models/swagger_root.dart';
 import 'package:collection/collection.dart';
 
-abstract class SwaggerEnumsGenerator {
+abstract class SwaggerEnumsGenerator extends SwaggerGeneratorBase {
+  final GeneratorOptions _options;
+
+  @override
+  GeneratorOptions get options => _options;
+
   static const String defaultEnumFieldName = 'value_';
   static const String defaultEnumValueName = 'swaggerGeneratedUnknown';
 
+  SwaggerEnumsGenerator(this._options);
+
   String generate(Map<String, dynamic> map, String fileName);
 
   String generateFromMap(
@@ -35,7 +43,7 @@ abstract class SwaggerEnumsGenerator {
     final enumsFromClasses = definitions.keys
         .map((String className) {
           return generateEnumsFromClasses(
-            SwaggerModelsGenerator.getValidatedClassName(className.pascalCase),
+            getValidatedClassName(className.pascalCase),
             definitions[className] as Map<String, dynamic>,
             definitions,
           );
@@ -81,7 +89,7 @@ $enumsFromRequestBodies
           }
 
           return generateEnumsFromClasses(
-            SwaggerModelsGenerator.getValidatedClassName(className.pascalCase),
+            getValidatedClassName(className.pascalCase),
             schema as Map<String, dynamic>,
             {},
           );
@@ -111,7 +119,7 @@ $enumsFromRequestBodies
           }
 
           return generateEnumsFromClasses(
-            SwaggerModelsGenerator.getValidatedClassName(className.pascalCase),
+            getValidatedClassName(className.pascalCase),
             schema as Map<String, dynamic>,
             {},
           );
@@ -122,24 +130,6 @@ $enumsFromRequestBodies
     return enumsFromRequestBodies;
   }
 
-  static SwaggerRequestParameter getOriginalOrOverriddenRequestParameter(
-      SwaggerRequestParameter swaggerRequestParameter,
-      List<SwaggerRequestParameter> definedParameters) {
-    if (swaggerRequestParameter.ref.isEmpty || definedParameters.isEmpty) {
-      return swaggerRequestParameter;
-    }
-
-    final parameterClassName = swaggerRequestParameter.ref.split('/').last;
-
-    final neededParameter = definedParameters.firstWhere(
-        (SwaggerRequestParameter element) =>
-            element.name == parameterClassName ||
-            element.key == parameterClassName,
-        orElse: () => swaggerRequestParameter);
-
-    return neededParameter;
-  }
-
   String generateEnumsContentFromRequests(
       Map<String, dynamic> map, String fileName) {
     final enumNames = <String>[];
@@ -177,10 +167,10 @@ $enumsFromRequestBodies
         for (var p = 0; p < swaggerRequest.parameters.length; p++) {
           final swaggerRequestParameter = swaggerRequest.parameters[p];
 
-          var name = SwaggerModelsGenerator.generateRequestEnumName(
+          var name = generateRequestEnumName(
               path, requestType, swaggerRequestParameter.name);
 
-          name = SwaggerModelsGenerator.getValidatedClassName(name);
+          name = getValidatedClassName(name);
 
           if (enumNames.contains(name)) {
             continue;
@@ -224,7 +214,7 @@ $enumsFromRequestBodies
 
     final enumMap = '''
 \n\tconst \$${enumName}Map = {
-\t${getEnumValuesMapContent(enumName, enumValues)}
+\t${getEnumValuesMapContent(enumName, enumValues: enumValues, enumValuesNames: [])}
       };
       ''';
 
@@ -277,17 +267,26 @@ $enumMap
     return resultStrings.join(',\n');
   }
 
-  String getEnumValuesMapContent(String enumName, List<String> enumValues) {
+  String getEnumValuesMapContent(String enumName,
+      {required List<String> enumValues,
+      required List<String> enumValuesNames}) {
     final neededStrings = <String>[];
     final fields = <String>[];
 
-    for (var value in enumValues) {
-      var validatedValue = getValidatedEnumFieldName(value);
+    for (int i = 0; i < enumValues.length; i++) {
+      final value = enumValues[i];
+      var validatedValue = value;
 
       while (fields.contains(validatedValue)) {
         validatedValue += '\$';
       }
 
+      if (enumValuesNames.length == enumValues.length) {
+        validatedValue = enumValuesNames[i];
+      }
+
+      validatedValue = getValidatedEnumFieldName(validatedValue);
+
       fields.add(validatedValue);
       neededStrings.add(
           '\t$enumName.$validatedValue: \'${value.replaceAll('\$', '\\\$')}\'');
@@ -319,52 +318,6 @@ $enumMap
     return result.lower;
   }
 
-  static List<String> getEnumNamesFromRequests(Map<String, dynamic> map) {
-    final enumNames = <String>[];
-    final swaggerRoot = SwaggerRoot.fromJson(map);
-
-    //Link defined parameters with requests
-    swaggerRoot.paths.forEach((String path, SwaggerPath swaggerPath) {
-      swaggerPath.requests.forEach((String req, SwaggerRequest swaggerRequest) {
-        swaggerRequest.parameters = swaggerRequest.parameters
-            .map((SwaggerRequestParameter parameter) =>
-                getOriginalOrOverriddenRequestParameter(parameter,
-                    swaggerRoot.components?.parameters.values.toList() ?? []))
-            .toList();
-      });
-    });
-
-    swaggerRoot.paths.forEach((String path, SwaggerPath swaggerPath) {
-      swaggerPath.requests
-          .forEach((String requestType, SwaggerRequest swaggerRequest) {
-        if (swaggerRequest.parameters.isEmpty) {
-          return;
-        }
-
-        for (var p = 0; p < swaggerRequest.parameters.length; p++) {
-          final swaggerRequestParameter = swaggerRequest.parameters[p];
-
-          var name = SwaggerModelsGenerator.generateRequestEnumName(
-              path, requestType, swaggerRequestParameter.name);
-
-          if (enumNames.contains(name)) {
-            continue;
-          }
-
-          final enumValues = swaggerRequestParameter.schema?.enumValues ??
-              swaggerRequestParameter.items?.enumValues ??
-              [];
-
-          if (enumValues.isNotEmpty) {
-            enumNames.add(name);
-          }
-        }
-      });
-    });
-
-    return enumNames;
-  }
-
   String generateEnumsContentFromModelProperties(
       Map<String, dynamic> map, String className) {
     if (map.isEmpty) {
@@ -395,14 +348,12 @@ $enumMap
 
   String generateEnumContentIfPossible(
       Map<String, dynamic> map, String enumName) {
-    enumName = SwaggerModelsGenerator.getValidatedClassName(enumName);
+    enumName = getValidatedClassName(enumName);
 
     if (map['enum'] != null) {
       final enumValues =
           (map['enum'] as List<dynamic>).map((e) => e.toString()).toList();
 
-      final stringValues = enumValues.map((e) => e.toString()).toList();
-
       final enumValuesNames =
           (map[kEnumNames] ?? map[kEnumVarnames]) as List? ?? [];
 
@@ -411,18 +362,14 @@ $enumMap
         enumValuesNamesList = enumValuesNames.map((e) => e.toString()).toList();
       }
 
-      final mapValues = enumValuesNamesList.length == stringValues.length
-          ? enumValuesNamesList
-          : stringValues;
+      final isInteger = kIntegerTypes.contains(map['type']);
 
       final enumMap = '''
 \n\tconst \$${enumName}Map = {
-\t${getEnumValuesMapContent(enumName, mapValues)}
+\t${getEnumValuesMapContent(enumName, enumValues: enumValues, enumValuesNames: enumValuesNamesList)}
       };
       ''';
 
-      final isInteger = kIntegerTypes.contains(map['type']);
-
       return """
 enum ${enumName.capitalize} {
 \t@JsonValue('$defaultEnumValueName')\n  $defaultEnumValueName,
@@ -443,11 +390,6 @@ $enumMap
     }
   }
 
-  String generateEnumName(String className, String enumName) {
-    return SwaggerModelsGenerator.getValidatedClassName(
-        '${className.capitalize}_$enumName');
-  }
-
   String generateEnumsFromClasses(
     String className,
     Map<String, dynamic> map,
diff --git a/lib/src/code_generators/swagger_generator_base.dart b/lib/src/code_generators/swagger_generator_base.dart
new file mode 100644
index 00000000..2199700b
--- /dev/null
+++ b/lib/src/code_generators/swagger_generator_base.dart
@@ -0,0 +1,181 @@
+import 'package:recase/recase.dart';
+import 'package:swagger_dart_code_generator/src/code_generators/constants.dart';
+import 'package:swagger_dart_code_generator/src/exception_words.dart';
+import 'package:swagger_dart_code_generator/src/extensions/string_extension.dart';
+import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
+import 'package:swagger_dart_code_generator/src/swagger_models/requests/swagger_request.dart';
+import 'package:swagger_dart_code_generator/src/swagger_models/requests/swagger_request_parameter.dart';
+import 'package:swagger_dart_code_generator/src/swagger_models/swagger_path.dart';
+import 'package:swagger_dart_code_generator/src/swagger_models/swagger_root.dart';
+
+abstract class SwaggerGeneratorBase {
+  GeneratorOptions get options;
+
+  String getValidatedClassName(
+    String className,
+  ) {
+    if (kBasicTypes.contains(className)) {
+      return className;
+    }
+
+    if (exceptionWords.contains(className)) {
+      return 'Object';
+    }
+
+    if (className.isEmpty) {
+      return className;
+    }
+
+    final isEnum = className.startsWith('enums.');
+
+    if (isEnum) {
+      className = className.substring(6);
+    }
+
+    final words = className.split('\$');
+
+    final result = words
+        .map((e) => e.pascalCase
+            .split(RegExp(r'\W+|\_'))
+            .map((String str) => str.capitalize)
+            .join())
+        .join('\$')
+        .replaceFirst(RegExp(options.cutFromModelNames), '');
+
+    if (kKeyClasses.contains(result)) {
+      return '$result\$';
+    }
+
+    if (isEnum) {
+      return 'enums.$result';
+    }
+
+    if (result.startsWith(RegExp('[0-9]'))) {
+      return '\$$result';
+    }
+
+    return result.replaceFirst(options.cutFromModelNames, '');
+  }
+
+  String generateEnumName(String className, String enumName) {
+    return getValidatedClassName('${className.capitalize}_$enumName');
+  }
+
+  String generateRequestEnumName(
+      String path, String requestType, String parameterName) {
+    if (path == '/') {
+      path = '\$';
+    }
+
+    path = path.split('{').map((e) => e.capitalize).join();
+    path = path.split('}').map((e) => e.capitalize).join();
+
+    final correctedPath = generateFieldName(path);
+
+    final result =
+        '${correctedPath.capitalize}${requestType.capitalize}${parameterName.capitalize}';
+
+    return getValidatedClassName(result);
+  }
+
+  String generateFieldName(String jsonKey) {
+    final forbiddenCharacters = <String>['#'];
+
+    jsonKey = jsonKey.camelCase;
+
+    for (var element in forbiddenCharacters) {
+      if (jsonKey.startsWith(element)) {
+        jsonKey = '\$forbiddenFieldName';
+      }
+    }
+
+    if (jsonKey.startsWith(RegExp('[0-9]')) ||
+        exceptionWords.contains(jsonKey)) {
+      jsonKey = '\$' + jsonKey;
+    }
+
+    if (kBasicTypes.contains(jsonKey)) {
+      jsonKey = '\$' + jsonKey;
+    }
+
+    return jsonKey;
+  }
+
+  List<String> getEnumNamesFromRequests(Map<String, dynamic> map) {
+    final enumNames = <String>[];
+    final swaggerRoot = SwaggerRoot.fromJson(map);
+
+    //Link defined parameters with requests
+    swaggerRoot.paths.forEach((String path, SwaggerPath swaggerPath) {
+      swaggerPath.requests.forEach((String req, SwaggerRequest swaggerRequest) {
+        swaggerRequest.parameters = swaggerRequest.parameters
+            .map((SwaggerRequestParameter parameter) =>
+                getOriginalOrOverriddenRequestParameter(parameter,
+                    swaggerRoot.components?.parameters.values.toList() ?? []))
+            .toList();
+      });
+    });
+
+    swaggerRoot.paths.forEach((String path, SwaggerPath swaggerPath) {
+      swaggerPath.requests
+          .forEach((String requestType, SwaggerRequest swaggerRequest) {
+        if (swaggerRequest.parameters.isEmpty) {
+          return;
+        }
+
+        for (var p = 0; p < swaggerRequest.parameters.length; p++) {
+          final swaggerRequestParameter = swaggerRequest.parameters[p];
+
+          var name = generateRequestEnumName(
+              path, requestType, swaggerRequestParameter.name);
+
+          if (enumNames.contains(name)) {
+            continue;
+          }
+
+          final enumValues = swaggerRequestParameter.schema?.enumValues ??
+              swaggerRequestParameter.items?.enumValues ??
+              [];
+
+          if (enumValues.isNotEmpty) {
+            enumNames.add(name);
+          }
+        }
+      });
+    });
+
+    return enumNames;
+  }
+
+  SwaggerRequestParameter getOriginalOrOverriddenRequestParameter(
+      SwaggerRequestParameter swaggerRequestParameter,
+      List<SwaggerRequestParameter> definedParameters) {
+    if (swaggerRequestParameter.ref.isEmpty || definedParameters.isEmpty) {
+      return swaggerRequestParameter;
+    }
+
+    final parameterClassName = swaggerRequestParameter.ref.split('/').last;
+
+    final neededParameter = definedParameters.firstWhere(
+        (SwaggerRequestParameter element) =>
+            element.name == parameterClassName ||
+            element.key == parameterClassName,
+        orElse: () => swaggerRequestParameter);
+
+    return neededParameter;
+  }
+
+  String generateRequestName(String path, String requestType) {
+    if (path == '/') {
+      path = '\$';
+    }
+
+    path = path.split('{').map((e) => e.capitalize).join();
+    path = path.split('}').map((e) => e.capitalize).join();
+    path = path.split(',').map((e) => e.capitalize).join();
+
+    final correctedPath = getValidatedClassName(path);
+
+    return '${correctedPath.capitalize}${requestType.capitalize}'.camelCase;
+  }
+}
diff --git a/lib/src/code_generators/swagger_models_generator.dart b/lib/src/code_generators/swagger_models_generator.dart
index d7e49c2a..b3d544f5 100644
--- a/lib/src/code_generators/swagger_models_generator.dart
+++ b/lib/src/code_generators/swagger_models_generator.dart
@@ -2,37 +2,39 @@ import 'dart:convert';
 
 import 'package:collection/collection.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/constants.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_enums_generator.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/v3/swagger_enums_generator_v3.dart';
+import 'package:swagger_dart_code_generator/src/code_generators/swagger_generator_base.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 import 'package:recase/recase.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/v2/swagger_enums_generator_v2.dart';
 import 'package:swagger_dart_code_generator/src/extensions/string_extension.dart';
 import 'package:swagger_dart_code_generator/src/exception_words.dart';
 
 import 'constants.dart';
 
-abstract class SwaggerModelsGenerator {
-  String generate(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options);
-  String generateResponses(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options);
+abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
+  final GeneratorOptions _options;
 
-  String generateRequestBodies(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options);
+  @override
+  GeneratorOptions get options => _options;
+
+  SwaggerModelsGenerator(this._options);
+
+  String generate(Map<String, dynamic> map, String fileName);
+  String generateResponses(Map<String, dynamic> map, String fileName);
+
+  String generateRequestBodies(Map<String, dynamic> map, String fileName);
   String getExtendsString(Map<String, dynamic> map);
   List<String> getAllListEnumNames(Map<String, dynamic> map);
 
   String generateModelClassContent(
-      Map<String, dynamic> rootMap,
-      String className,
-      Map<String, dynamic> map,
-      Map<String, dynamic> schemas,
-      List<DefaultValueMap> defaultValues,
-      bool useDefaultNullForLists,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      GeneratorOptions options) {
+    Map<String, dynamic> rootMap,
+    String className,
+    Map<String, dynamic> map,
+    Map<String, dynamic> schemas,
+    List<DefaultValueMap> defaultValues,
+    bool useDefaultNullForLists,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+  ) {
     if (map['enum'] != null) {
       return '';
     }
@@ -60,13 +62,11 @@ abstract class SwaggerModelsGenerator {
       useDefaultNullForLists,
       allEnumNames,
       allEnumListNames,
-      options,
     );
   }
 
-  static Map<String, dynamic> getClassesFromInnerClasses(
+  Map<String, dynamic> getClassesFromInnerClasses(
     Map<String, dynamic> classes,
-    GeneratorOptions options,
   ) {
     final result = <String, dynamic>{};
 
@@ -94,15 +94,14 @@ abstract class SwaggerModelsGenerator {
     });
 
     if (result.isNotEmpty) {
-      result.addAll(getClassesFromInnerClasses(result, options));
+      result.addAll(getClassesFromInnerClasses(result));
     }
 
     return result;
   }
 
-  static Map<String, dynamic> getClassesFromResponses(
+  Map<String, dynamic> getClassesFromResponses(
     Map<String, dynamic> map,
-    GeneratorOptions options,
   ) {
     final results = <String, dynamic>{};
 
@@ -152,8 +151,7 @@ abstract class SwaggerModelsGenerator {
     return results;
   }
 
-  static Map<String, dynamic> getClassesFromSchemasResponses(
-      String dartCode, GeneratorOptions options) {
+  static Map<String, dynamic> getClassesFromSchemasResponses(String dartCode) {
     final swagger = jsonDecode(dartCode);
 
     final results = <String, dynamic>{};
@@ -172,12 +170,8 @@ abstract class SwaggerModelsGenerator {
     return responses;
   }
 
-  String generateBase(
-      Map<String, dynamic> map,
-      String fileName,
-      GeneratorOptions options,
-      Map<String, dynamic> classes,
-      bool generateFromJsonToJsonForRequests) {
+  String generateBase(Map<String, dynamic> map, String fileName,
+      Map<String, dynamic> classes, bool generateFromJsonToJsonForRequests) {
     final allEnumsNames = getAllEnumNames(map);
     final allEnumListNames = getAllListEnumNames(map);
 
@@ -186,11 +180,10 @@ abstract class SwaggerModelsGenerator {
             allEnumsNames, options.enumsCaseSensitive)
         : '';
 
-    final classesFromResponses = getClassesFromResponses(map, options);
+    final classesFromResponses = getClassesFromResponses(map);
     classes.addAll(classesFromResponses);
 
-    final classesFromInnerClasses =
-        getClassesFromInnerClasses(classes, options);
+    final classesFromInnerClasses = getClassesFromInnerClasses(classes);
 
     classes.addAll(classesFromInnerClasses);
 
@@ -212,7 +205,6 @@ abstract class SwaggerModelsGenerator {
         options.useDefaultNullForLists,
         allEnumsNames,
         allEnumListNames,
-        options,
       );
     }).join('\n');
 
@@ -227,49 +219,6 @@ abstract class SwaggerModelsGenerator {
     return results;
   }
 
-  static String getValidatedClassName(String className) {
-    if (kBasicTypes.contains(className)) {
-      return className;
-    }
-
-    if (exceptionWords.contains(className)) {
-      return 'Object';
-    }
-
-    if (className.isEmpty) {
-      return className;
-    }
-
-    final isEnum = className.startsWith('enums.');
-
-    if (isEnum) {
-      className = className.substring(6);
-    }
-
-    final words = className.split('\$');
-
-    final result = words
-        .map((e) => e.pascalCase
-            .split(RegExp(r'\W+|\_'))
-            .map((String str) => str.capitalize)
-            .join())
-        .join('\$');
-
-    if (kKeyClasses.contains(result)) {
-      return '$result\$';
-    }
-
-    if (isEnum) {
-      return 'enums.$result';
-    }
-
-    if (result.startsWith(RegExp('[0-9]'))) {
-      return '\$$result';
-    }
-
-    return result;
-  }
-
   static String getValidatedParameterName(String parameterName) {
     if (parameterName.isEmpty) {
       return parameterName;
@@ -347,7 +296,7 @@ abstract class SwaggerModelsGenerator {
             parameter['format'] == 'date') {
           return 'DateTime';
         } else if (parameter['enum'] != null) {
-          return 'enums.${SwaggerModelsGenerator.getValidatedClassName(SwaggerEnumsGeneratorV2().generateEnumName(SwaggerModelsGenerator.getValidatedClassName(className), parameterName))}';
+          return 'enums.${getValidatedClassName(generateEnumName(getValidatedClassName(className), parameterName))}';
         }
         return 'String';
       case 'Date':
@@ -366,60 +315,6 @@ abstract class SwaggerModelsGenerator {
     }
   }
 
-  static String generateFieldName(String jsonKey) {
-    final forbiddenCharacters = <String>['#'];
-
-    jsonKey = jsonKey.camelCase;
-
-    for (var element in forbiddenCharacters) {
-      if (jsonKey.startsWith(element)) {
-        jsonKey = '\$forbiddenFieldName';
-      }
-    }
-
-    if (jsonKey.startsWith(RegExp('[0-9]')) ||
-        exceptionWords.contains(jsonKey)) {
-      jsonKey = '\$' + jsonKey;
-    }
-
-    if (kBasicTypes.contains(jsonKey)) {
-      jsonKey = '\$' + jsonKey;
-    }
-
-    return jsonKey;
-  }
-
-  static String generateRequestEnumName(
-      String path, String requestType, String parameterName) {
-    if (path == '/') {
-      path = '\$';
-    }
-
-    path = path.split('{').map((e) => e.capitalize).join();
-    path = path.split('}').map((e) => e.capitalize).join();
-
-    final correctedPath = generateFieldName(path);
-
-    final result =
-        '${correctedPath.capitalize}${requestType.capitalize}${parameterName.capitalize}';
-
-    return SwaggerModelsGenerator.getValidatedClassName(result);
-  }
-
-  static String generateRequestName(String path, String requestType) {
-    if (path == '/') {
-      path = '\$';
-    }
-
-    path = path.split('{').map((e) => e.capitalize).join();
-    path = path.split('}').map((e) => e.capitalize).join();
-    path = path.split(',').map((e) => e.capitalize).join();
-
-    final correctedPath = SwaggerModelsGenerator.getValidatedClassName(path);
-
-    return '${correctedPath.capitalize}${requestType.capitalize}'.camelCase;
-  }
-
   String generateDefaultValueFromMap(DefaultValueMap map) {
     switch (map.typeName) {
       case 'int':
@@ -431,7 +326,7 @@ abstract class SwaggerModelsGenerator {
     }
   }
 
-  String generateIncludeIfNullString(GeneratorOptions options) {
+  String generateIncludeIfNullString() {
     if (options.includeIfNull == null) {
       return '';
     }
@@ -440,11 +335,11 @@ abstract class SwaggerModelsGenerator {
   }
 
   String generatePropertyContentByDefault(
-      Map<String, dynamic> propertyEntryMap,
-      String propertyName,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      GeneratorOptions options) {
+    Map<String, dynamic> propertyEntryMap,
+    String propertyName,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+  ) {
     var typeName = '';
     final originalRef = propertyEntryMap['originalRef'];
 
@@ -462,7 +357,7 @@ abstract class SwaggerModelsGenerator {
 
     final dateToJsonValue = generateToJsonForDate(propertyEntryMap);
 
-    final includeIfNullString = generateIncludeIfNullString(options);
+    final includeIfNullString = generateIncludeIfNullString();
 
     if (typeName != kDynamic) {
       typeName += '?';
@@ -470,7 +365,7 @@ abstract class SwaggerModelsGenerator {
 
     final jsonKeyContent =
         "@JsonKey(name: '$propertyName'$includeIfNullString$dateToJsonValue$unknownEnumValue)\n";
-    return '\t$jsonKeyContent\tfinal $typeName ${SwaggerModelsGenerator.generateFieldName(propertyName)};';
+    return '\t$jsonKeyContent\tfinal $typeName ${generateFieldName(propertyName)};';
   }
 
   String generateUnknownEnumValue(List<String> allEnumNames,
@@ -514,7 +409,6 @@ abstract class SwaggerModelsGenerator {
       String className,
       List<String> allEnumNames,
       List<String> allEnumListNames,
-      GeneratorOptions options,
       Map<String, String> basicTypesMap) {
     final propertySchema = propertyEntryMap['schema'] as Map<String, dynamic>;
     var parameterName = propertySchema['\$ref'].toString().split('/').last;
@@ -527,7 +421,7 @@ abstract class SwaggerModelsGenerator {
           propertyName, propertyEntryMap, options.modelPostfix, parameterName));
     }
 
-    final includeIfNullString = generateIncludeIfNullString(options);
+    final includeIfNullString = generateIncludeIfNullString();
 
     final allEnumsNamesWithoutPrefix =
         allEnumNames.map((e) => e.replaceFirst('enums.', '')).toList();
@@ -546,13 +440,12 @@ abstract class SwaggerModelsGenerator {
     final jsonKeyContent =
         "@JsonKey(name: '$propertyKey'$includeIfNullString$unknownEnumValue$dateToJsonValue)\n";
 
-    return '\t$jsonKeyContent\tfinal $typeName? ${SwaggerModelsGenerator.generateFieldName(propertyName)};';
+    return '\t$jsonKeyContent\tfinal $typeName? ${generateFieldName(propertyName)};';
   }
 
   String generatePropertyContentByAllOf({
     required Map<String, dynamic> propertyEntryMap,
     required String propertyKey,
-    required GeneratorOptions options,
     required List<String> allEnumNames,
     required List<String> allEnumListNames,
     required String propertyName,
@@ -563,11 +456,11 @@ abstract class SwaggerModelsGenerator {
     if (allOf.length != 1) {
       typeName = kDynamic;
     } else {
-      typeName = SwaggerModelsGenerator.getValidatedClassName(
-          allOf.first['\$ref'].toString().getRef());
+      typeName =
+          getValidatedClassName(allOf.first['\$ref'].toString().getRef());
     }
 
-    final includeIfNullString = generateIncludeIfNullString(options);
+    final includeIfNullString = generateIncludeIfNullString();
 
     final unknownEnumValue = generateUnknownEnumValue(
         allEnumNames, allEnumListNames, typeName, false);
@@ -585,7 +478,6 @@ abstract class SwaggerModelsGenerator {
       String className,
       List<String> allEnumNames,
       List<String> allEnumListNames,
-      GeneratorOptions options,
       Map<String, String> basicTypesMap) {
     final parameterName = propertyEntryMap['\$ref'].toString().split('/').last;
     String typeName;
@@ -595,7 +487,7 @@ abstract class SwaggerModelsGenerator {
       typeName = getValidatedClassName(getParameterTypeName(className,
           propertyName, propertyEntryMap, options.modelPostfix, parameterName));
 
-      typeName = SwaggerModelsGenerator.getValidatedClassName(typeName);
+      typeName = getValidatedClassName(typeName);
     }
 
     final allEnumsNamesWithoutPrefix =
@@ -615,7 +507,7 @@ abstract class SwaggerModelsGenerator {
       typeName = 'List<$typeName>';
     }
 
-    final includeIfNullString = generateIncludeIfNullString(options);
+    final includeIfNullString = generateIncludeIfNullString();
 
     final jsonKeyContent =
         "@JsonKey(name: '$propertyKey'$includeIfNullString$unknownEnumValue)\n";
@@ -628,10 +520,8 @@ abstract class SwaggerModelsGenerator {
     String className,
     List<String> allEnumNames,
     List<String> allEnumListNames,
-    GeneratorOptions options,
   ) {
-    final enumName = SwaggerModelsGenerator.getValidatedClassName(
-        SwaggerEnumsGeneratorV2().generateEnumName(className, key));
+    final enumName = getValidatedClassName(generateEnumName(className, key));
 
     allEnumNames.add(enumName);
 
@@ -639,18 +529,17 @@ abstract class SwaggerModelsGenerator {
             allEnumNames, allEnumListNames, enumName, false)
         .substring(2);
 
-    final includeIfNullString = generateIncludeIfNullString(options);
+    final includeIfNullString = generateIncludeIfNullString();
 
     return '''
   @JsonKey($unknownEnumValue$includeIfNullString)
-  final ${className.capitalize + key.capitalize}? ${SwaggerModelsGenerator.generateFieldName(key)};''';
+  final ${className.capitalize + key.capitalize}? ${generateFieldName(key)};''';
   }
 
   String _generateListPropertyTypeName({
     required List<String> allEnumNames,
     required List<String> allEnumListNames,
     required Map<String, dynamic> propertyEntryMap,
-    required GeneratorOptions options,
     required Map<String, String> basicTypesMap,
     required String propertyName,
     required String className,
@@ -689,7 +578,7 @@ abstract class SwaggerModelsGenerator {
       }
 
       if (typeName.isNotEmpty) {
-        typeName = SwaggerModelsGenerator.getValidatedClassName(typeName);
+        typeName = getValidatedClassName(typeName);
       }
 
       if (typeName.isEmpty) {
@@ -699,7 +588,6 @@ abstract class SwaggerModelsGenerator {
             allEnumNames: allEnumNames,
             basicTypesMap: basicTypesMap,
             className: className,
-            options: options,
             propertyEntryMap: items as Map<String, dynamic>,
             propertyName: propertyName,
           ).asList();
@@ -732,14 +620,12 @@ abstract class SwaggerModelsGenerator {
       bool useDefaultNullForLists,
       List<String> allEnumNames,
       List<String> allEnumListNames,
-      GeneratorOptions options,
       Map<String, String> basicTypesMap) {
     final typeName = _generateListPropertyTypeName(
       allEnumListNames: allEnumListNames,
       allEnumNames: allEnumNames,
       basicTypesMap: basicTypesMap,
       className: className,
-      options: options,
       propertyEntryMap: propertyEntryMap,
       propertyName: propertyName,
     );
@@ -747,7 +633,7 @@ abstract class SwaggerModelsGenerator {
     final unknownEnumValue = generateUnknownEnumValue(
         allEnumNames, allEnumListNames, typeName, true);
 
-    final includeIfNullString = generateIncludeIfNullString(options);
+    final includeIfNullString = generateIncludeIfNullString();
 
     String jsonKeyContent;
     if (unknownEnumValue.isEmpty) {
@@ -758,19 +644,19 @@ abstract class SwaggerModelsGenerator {
           "@JsonKey(name: '$propertyKey'$includeIfNullString$unknownEnumValue)\n";
     }
 
-    return '$jsonKeyContent  final List<$typeName>? ${SwaggerModelsGenerator.generateFieldName(propertyName)};';
+    return '$jsonKeyContent  final List<$typeName>? ${generateFieldName(propertyName)};';
   }
 
   String generateGeneralPropertyContent(
-      String propertyName,
-      String propertyKey,
-      String className,
-      List<DefaultValueMap> defaultValues,
-      Map<String, dynamic> val,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      GeneratorOptions options) {
-    final includeIfNullString = generateIncludeIfNullString(options);
+    String propertyName,
+    String propertyKey,
+    String className,
+    List<DefaultValueMap> defaultValues,
+    Map<String, dynamic> val,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+  ) {
+    final includeIfNullString = generateIncludeIfNullString();
 
     var jsonKeyContent = "@JsonKey(name: '$propertyKey'$includeIfNullString";
 
@@ -835,7 +721,6 @@ abstract class SwaggerModelsGenerator {
       bool useDefaultNullForLists,
       List<String> allEnumsNames,
       List<String> allEnumListNames,
-      GeneratorOptions options,
       Map<String, String> basicTypesMap) {
     switch (propertyEntryMap['type'] as String) {
       case 'array':
@@ -847,7 +732,6 @@ abstract class SwaggerModelsGenerator {
           useDefaultNullForLists,
           allEnumsNames,
           allEnumListNames,
-          options,
           basicTypesMap,
         );
       case 'enum':
@@ -856,7 +740,6 @@ abstract class SwaggerModelsGenerator {
           className,
           allEnumsNames,
           allEnumListNames,
-          options,
         );
       default:
         return generateGeneralPropertyContent(
@@ -867,7 +750,6 @@ abstract class SwaggerModelsGenerator {
           propertyEntryMap,
           allEnumsNames,
           allEnumListNames,
-          options,
         );
     }
   }
@@ -882,15 +764,15 @@ abstract class SwaggerModelsGenerator {
   }
 
   String generatePropertiesContent(
-      Map<String, dynamic> rootMap,
-      Map<String, dynamic> propertiesMap,
-      Map<String, dynamic> schemas,
-      String className,
-      List<DefaultValueMap> defaultValues,
-      bool useDefaultNullForLists,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      GeneratorOptions options) {
+    Map<String, dynamic> rootMap,
+    Map<String, dynamic> propertiesMap,
+    Map<String, dynamic> schemas,
+    String className,
+    List<DefaultValueMap> defaultValues,
+    bool useDefaultNullForLists,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+  ) {
     if (propertiesMap.isEmpty) {
       return '';
     }
@@ -926,14 +808,12 @@ abstract class SwaggerModelsGenerator {
             useDefaultNullForLists,
             allEnumNames,
             allEnumListNames,
-            options,
             basicTypesMap));
       } else if (propertyEntryMap['allOf'] != null) {
         results.add(generatePropertyContentByAllOf(
           propertyEntryMap: propertyEntryMap,
           allEnumListNames: allEnumListNames,
           allEnumNames: allEnumNames,
-          options: options,
           propertyKey: propertyKey,
           propertyName: propertyName,
         ));
@@ -945,7 +825,6 @@ abstract class SwaggerModelsGenerator {
             className,
             allEnumNames,
             allEnumListNames,
-            options,
             basicTypesMap));
       } else if (propertyEntryMap['schema'] != null) {
         results.add(generatePropertyContentBySchema(
@@ -955,11 +834,14 @@ abstract class SwaggerModelsGenerator {
             className,
             allEnumNames,
             allEnumListNames,
-            options,
             basicTypesMap));
       } else {
-        results.add(generatePropertyContentByDefault(propertyEntryMap,
-            propertyName, allEnumNames, allEnumListNames, options));
+        results.add(generatePropertyContentByDefault(
+          propertyEntryMap,
+          propertyName,
+          allEnumNames,
+          allEnumListNames,
+        ));
       }
     }
 
@@ -1040,8 +922,8 @@ abstract class SwaggerModelsGenerator {
   }
 
   String generateEnumFromJsonToJson(String enumName, bool enumsCaseSensitive) {
-    final neededName = SwaggerModelsGenerator.getValidatedClassName(
-        enumName.replaceFirst('enums.', ''));
+    final neededName =
+        getValidatedClassName(enumName.replaceFirst('enums.', ''));
 
     final toLowerCaseString = !enumsCaseSensitive ? '.toLowerCase()' : '';
 
@@ -1103,7 +985,6 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
   String generateConstructorPropertiesContent(
     String className,
     Map<String, dynamic> entityMap,
-    GeneratorOptions options,
     List<DefaultValueMap> defaultValues,
     List<String> allEnumNames,
     List<String> allEnumListNames,
@@ -1127,21 +1008,20 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
   }
 
   String generateModelClassString(
-      Map<String, dynamic> rootMap,
-      String className,
-      Map<String, dynamic> map,
-      Map<String, dynamic> schemas,
-      List<DefaultValueMap> defaultValues,
-      bool useDefaultNullForLists,
-      List<String> allEnumNames,
-      List<String> allEnumListNames,
-      GeneratorOptions options) {
+    Map<String, dynamic> rootMap,
+    String className,
+    Map<String, dynamic> map,
+    Map<String, dynamic> schemas,
+    List<DefaultValueMap> defaultValues,
+    bool useDefaultNullForLists,
+    List<String> allEnumNames,
+    List<String> allEnumListNames,
+  ) {
     final properties = getModelProperties(map, schemas);
 
     final generatedConstructorProperties = generateConstructorPropertiesContent(
       className,
       properties,
-      options,
       defaultValues,
       allEnumNames,
       allEnumListNames,
@@ -1156,7 +1036,6 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
       useDefaultNullForLists,
       allEnumNames,
       allEnumListNames,
-      options,
     );
 
     final validatedClassName =
@@ -1314,7 +1193,7 @@ $allHashComponents;
   }
 
   List<String> getAllEnumNames(Map<String, dynamic> map) {
-    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
+    final results = getEnumNamesFromRequests(map);
 
     final components = map['components'] as Map<String, dynamic>?;
 
@@ -1341,16 +1220,14 @@ $allHashComponents;
     schemas.forEach((className, map) {
       final mapMap = map as Map<String, dynamic>;
       if (mapMap.containsKey('enum')) {
-        results.add(
-            SwaggerModelsGenerator.getValidatedClassName(className.capitalize));
+        results.add(getValidatedClassName(className.capitalize));
         return;
       }
 
       if (mapMap['type'] == 'array' &&
           mapMap['items'] != null &&
           mapMap['items']['enum'] != null) {
-        results.add(
-            SwaggerModelsGenerator.getValidatedClassName(className.capitalize));
+        results.add(getValidatedClassName(className.capitalize));
         return;
       }
 
@@ -1400,10 +1277,8 @@ $allHashComponents;
         if (propertyValue.containsKey('enum') ||
             (propertyValue['items'] != null &&
                 propertyValue['items']['enum'] != null)) {
-          results.add(SwaggerModelsGenerator.getValidatedClassName(
-              SwaggerEnumsGeneratorV3().generateEnumName(
-                  SwaggerModelsGenerator.getValidatedClassName(className),
-                  propertyName)));
+          results.add(getValidatedClassName(generateEnumName(
+              getValidatedClassName(className), propertyName)));
         }
       });
     });
@@ -1433,8 +1308,7 @@ $allHashComponents;
           if (property.containsKey('enum') ||
               (property['items'] != null &&
                   property['items']['enum'] != null)) {
-            results.add(SwaggerEnumsGeneratorV3()
-                .generateEnumName(className, propertyName));
+            results.add(generateEnumName(className, propertyName));
           }
         });
       });
@@ -1465,8 +1339,7 @@ $allHashComponents;
           if (property.containsKey('enum') ||
               (property['items'] != null &&
                   property['items']['enum'] != null)) {
-            results.add(SwaggerEnumsGeneratorV3()
-                .generateEnumName(className, propertyName));
+            results.add(generateEnumName(className, propertyName));
           }
         });
       });
@@ -1479,8 +1352,7 @@ $allHashComponents;
     return resultsWithPrefix;
   }
 
-  static Map<String, dynamic> getRequestBodiesFromRequests(
-      Map<String, dynamic> map) {
+  Map<String, dynamic> getRequestBodiesFromRequests(Map<String, dynamic> map) {
     final paths = map['paths'] as Map<String, dynamic>? ?? {};
     if (paths.isEmpty) {
       return {};
@@ -1512,8 +1384,7 @@ $allHashComponents;
                   final className =
                       '${pathKey.pascalCase}${requestKey.pascalCase}\$$kRequestBody';
 
-                  result[SwaggerModelsGenerator.getValidatedClassName(
-                      className)] = requestBody;
+                  result[getValidatedClassName(className)] = requestBody;
                 }
               }
             }
diff --git a/lib/src/code_generators/swagger_requests_generator.dart b/lib/src/code_generators/swagger_requests_generator.dart
index 6fabd22e..69e94ea4 100644
--- a/lib/src/code_generators/swagger_requests_generator.dart
+++ b/lib/src/code_generators/swagger_requests_generator.dart
@@ -1,7 +1,6 @@
 import 'package:code_builder/code_builder.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_additions_generator.dart';
+import 'package:swagger_dart_code_generator/src/code_generators/swagger_generator_base.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_models_generator.dart';
 import 'package:swagger_dart_code_generator/src/extensions/string_extension.dart';
 import 'package:swagger_dart_code_generator/src/swagger_models/requests/swagger_request.dart';
 import 'package:swagger_dart_code_generator/src/swagger_models/requests/swagger_request_parameter.dart';
@@ -15,12 +14,18 @@ import 'package:swagger_dart_code_generator/src/extensions/parameter_extensions.
 
 import 'constants.dart';
 
-class SwaggerRequestsGenerator {
+class SwaggerRequestsGenerator extends SwaggerGeneratorBase {
+  final GeneratorOptions _options;
+
+  @override
+  GeneratorOptions get options => _options;
+
+  SwaggerRequestsGenerator(this._options);
+
   String generate({
     required Map<String, dynamic> map,
     required String className,
     required String fileName,
-    required GeneratorOptions options,
   }) {
     final swaggerRoot = SwaggerRoot.fromJson(map);
 
@@ -28,7 +33,6 @@ class SwaggerRequestsGenerator {
       swaggerRoot,
       className,
       fileName,
-      options,
     );
 
     return service.accept(DartEmitter()).toString();
@@ -38,18 +42,15 @@ class SwaggerRequestsGenerator {
     SwaggerRoot swaggerRoot,
     String className,
     String fileName,
-    GeneratorOptions options,
   ) {
     final allMethodsContent = _getAllMethodsContent(
       swaggerRoot: swaggerRoot,
-      options: options,
     );
 
-    final chopperClient = SwaggerAdditionsGenerator.getChopperClientContent(
+    final chopperClient = getChopperClientContent(
       className,
       swaggerRoot.host,
       swaggerRoot.basePath,
-      options,
     );
 
     return Class(
@@ -78,6 +79,12 @@ class SwaggerRequestsGenerator {
             ..type = Reference('ChopperClient?')
             ..name = 'client',
         ))
+        ..optionalParameters.add(Parameter(
+          (p) => p
+            ..named = true
+            ..type = Reference('Authenticator?')
+            ..name = 'authenticator',
+        ))
         ..optionalParameters.add(Parameter(
           (p) => p
             ..named = true
@@ -96,7 +103,6 @@ class SwaggerRequestsGenerator {
 
   List<Method> _getAllMethodsContent({
     required SwaggerRoot swaggerRoot,
-    required GeneratorOptions options,
   }) {
     final methods = <Method>[];
 
@@ -119,10 +125,10 @@ class SwaggerRequestsGenerator {
         }
 
         final methodName = _getRequestMethodName(
-            requestType: requestType,
-            swaggerRequest: swaggerRequest,
-            path: path,
-            options: options);
+          requestType: requestType,
+          swaggerRequest: swaggerRequest,
+          path: path,
+        );
 
         final parameters = _getAllParameters(
           swaggerRequest: swaggerRequest,
@@ -132,7 +138,6 @@ class SwaggerRequestsGenerator {
           path: path,
           requestType: requestType,
           root: swaggerRoot,
-          options: options,
         );
 
         final returnTypeName = _getReturnTypeName(
@@ -160,7 +165,6 @@ class SwaggerRequestsGenerator {
           ..docs.add(_getCommentsForMethod(
             methodDescription: swaggerRequest.summary,
             parameters: swaggerRequest.parameters,
-            options: options,
           ))
           ..name = methodName
           ..annotations
@@ -208,7 +212,7 @@ class SwaggerRequestsGenerator {
 
     final neededResponse = response.removeListOrStream();
     if (!kBasicTypes.contains(neededResponse)) {
-      results.add(SwaggerModelsGenerator.getValidatedClassName(neededResponse));
+      results.add(getValidatedClassName(neededResponse));
     }
 
     return results.where((element) => _isValidModelName(element)).toList();
@@ -303,14 +307,12 @@ class SwaggerRequestsGenerator {
   String _getCommentsForMethod({
     required String methodDescription,
     required List<SwaggerRequestParameter> parameters,
-    required GeneratorOptions options,
   }) {
     final parametersComments = parameters
         .map((SwaggerRequestParameter parameter) => _createSummaryParameters(
               parameter.name,
               parameter.description,
               parameter.inParameter,
-              options,
             ));
 
     final formattedDescription = methodDescription.split('\n').join('\n///');
@@ -321,10 +323,10 @@ class SwaggerRequestsGenerator {
   }
 
   String _createSummaryParameters(
-      String parameterName,
-      String parameterDescription,
-      String inParameter,
-      GeneratorOptions options) {
+    String parameterName,
+    String parameterDescription,
+    String inParameter,
+  ) {
     if (inParameter == kHeader && options.ignoreHeaders) {
       return '';
     }
@@ -362,7 +364,7 @@ class SwaggerRequestsGenerator {
         .map((e) => e.replaceAll('}', '').replaceAll('{', '').pascalCase)
         .join();
 
-    final result = SwaggerModelsGenerator.getValidatedClassName(
+    final result = getValidatedClassName(
         '$pathString ${requestType.pascalCase} $parameterName');
 
     return result.asEnum();
@@ -464,7 +466,6 @@ class SwaggerRequestsGenerator {
     required String requestType,
     required String modelPostfix,
     required SwaggerRoot root,
-    required GeneratorOptions options,
     required SwaggerPath swaggerPath,
   }) {
     final definedParameters = <String, SwaggerRequestParameter>{};
@@ -492,7 +493,7 @@ class SwaggerRequestsGenerator {
               ..name = swaggerParameter.name.asParameterName()
               ..named = true
               ..required = swaggerParameter.isRequired &&
-                  _getHeaderDefaultValue(swaggerParameter, options) == null &&
+                  _getHeaderDefaultValue(swaggerParameter) == null &&
                   swaggerParameter.inParameter != kHeader
               ..type = Reference(
                 _getParameterTypeName(
@@ -507,7 +508,7 @@ class SwaggerRequestsGenerator {
               ..annotations.add(
                 _getParameterAnnotation(swaggerParameter),
               )
-              ..defaultTo = _getHeaderDefaultValue(swaggerParameter, options),
+              ..defaultTo = _getHeaderDefaultValue(swaggerParameter),
           ),
         )
         .toList();
@@ -528,7 +529,7 @@ class SwaggerRequestsGenerator {
           typeName = requestBodyRef.getRef();
         }
 
-        typeName = SwaggerModelsGenerator.getValidatedClassName(typeName);
+        typeName = getValidatedClassName(typeName);
       }
 
       final schema = requestBody.content?.schema;
@@ -620,15 +621,12 @@ class SwaggerRequestsGenerator {
         }
 
         if (ref.isNotEmpty) {
-          return SwaggerModelsGenerator.getValidatedClassName(
-                  ref.withPostfix(modelPostfix))
-              .asList();
+          return getValidatedClassName(ref.withPostfix(modelPostfix)).asList();
         }
 
         return '';
       } else if (schema.type == kObject) {
-        return SwaggerModelsGenerator.getValidatedClassName(
-            '$requestPath\$$kRequestBody');
+        return getValidatedClassName('$requestPath\$$kRequestBody');
       }
 
       return kBasicTypesMap[schema.type] ?? schema.type;
@@ -643,15 +641,14 @@ class SwaggerRequestsGenerator {
         return kObject.pascalCase;
       }
 
-      return SwaggerModelsGenerator.getValidatedClassName(
+      return getValidatedClassName(
           schema.ref.getRef().withPostfix(modelPostfix));
     }
 
     return '';
   }
 
-  Code? _getHeaderDefaultValue(
-      SwaggerRequestParameter swaggerParameter, GeneratorOptions options) {
+  Code? _getHeaderDefaultValue(SwaggerRequestParameter swaggerParameter) {
     final overridenValue = options.defaultHeaderValuesMap.firstWhereOrNull(
         (map) =>
             map.headerName.toLowerCase() ==
@@ -666,14 +663,12 @@ class SwaggerRequestsGenerator {
 
   String _getRequestMethodName({
     required SwaggerRequest swaggerRequest,
-    required GeneratorOptions options,
     required String path,
     required String requestType,
   }) {
     String methodName;
     if (options.usePathForRequestNames || swaggerRequest.operationId.isEmpty) {
-      methodName =
-          SwaggerModelsGenerator.generateRequestName(path, requestType);
+      methodName = generateRequestName(path, requestType);
     } else {
       methodName = swaggerRequest.operationId;
     }
@@ -748,7 +743,7 @@ class SwaggerRequestsGenerator {
         return kObject.pascalCase;
       }
 
-      return ref.getRef() + modelPostfix;
+      return getValidatedClassName(ref.getRef() + modelPostfix);
     }
 
     return null;
@@ -804,8 +799,7 @@ class SwaggerRequestsGenerator {
       }
 
       final typeName =
-          SwaggerModelsGenerator.getValidatedClassName(schemaRef.getRef())
-              .withPostfix(modelPostfix);
+          getValidatedClassName(schemaRef.getRef()).withPostfix(modelPostfix);
 
       if (neededSchema.type == kArray) {
         return neededSchema.items?.ref
@@ -836,10 +830,9 @@ class SwaggerRequestsGenerator {
 
     final schemaItemsRef = content.schema?.items?.ref ?? '';
     if (schemaItemsRef.isNotEmpty) {
-      final result =
-          SwaggerModelsGenerator.getValidatedClassName(schemaItemsRef.getRef())
-              .withPostfix(modelPostfix)
-              .asList();
+      final result = getValidatedClassName(schemaItemsRef.getRef())
+          .withPostfix(modelPostfix)
+          .asList();
 
       return result;
     }
@@ -917,6 +910,35 @@ class SwaggerRequestsGenerator {
 
     return '';
   }
+
+  String getChopperClientContent(
+    String className,
+    String host,
+    String basePath,
+  ) {
+    final baseUrlString = options.withBaseUrl
+        ? "baseUrl:  baseUrl ?? 'http://$host$basePath'"
+        : '/*baseUrl: YOUR_BASE_URL*/';
+
+    final converterString = options.withConverter
+        ? 'converter: \$JsonSerializableConverter(),'
+        : 'converter: chopper.JsonConverter(),';
+
+    final chopperClientBody = '''
+    if(client!=null){
+      return _\$$className(client);
+    }
+
+    final newClient = ChopperClient(
+      services: [_\$$className()],
+      $converterString
+      interceptors: interceptors ?? [],
+      authenticator: authenticator,
+      $baseUrlString);
+    return _\$$className(newClient);
+''';
+    return chopperClientBody;
+  }
 }
 
 extension on SwaggerRequestParameter {
diff --git a/lib/src/code_generators/v2/swagger_enums_generator_v2.dart b/lib/src/code_generators/v2/swagger_enums_generator_v2.dart
index 510d8ceb..0f0a7c93 100644
--- a/lib/src/code_generators/v2/swagger_enums_generator_v2.dart
+++ b/lib/src/code_generators/v2/swagger_enums_generator_v2.dart
@@ -1,6 +1,9 @@
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_enums_generator.dart';
+import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 
 class SwaggerEnumsGeneratorV2 extends SwaggerEnumsGenerator {
+  SwaggerEnumsGeneratorV2(GeneratorOptions options) : super(options);
+
   @override
   String generate(Map<String, dynamic> map, String fileName) {
     final definitions = map['definitions'] as Map<String, dynamic>? ?? {};
diff --git a/lib/src/code_generators/v2/swagger_models_generator_v2.dart b/lib/src/code_generators/v2/swagger_models_generator_v2.dart
index 8e3475fc..374ccf89 100644
--- a/lib/src/code_generators/v2/swagger_models_generator_v2.dart
+++ b/lib/src/code_generators/v2/swagger_models_generator_v2.dart
@@ -1,31 +1,29 @@
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_enums_generator.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_models_generator.dart';
 import 'package:swagger_dart_code_generator/src/extensions/string_extension.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 
 class SwaggerModelsGeneratorV2 extends SwaggerModelsGenerator {
+  SwaggerModelsGeneratorV2(GeneratorOptions options) : super(options);
+
   @override
-  String generate(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
+  String generate(Map<String, dynamic> map, String fileName) {
     final definitions = map['definitions'] as Map<String, dynamic>?;
-    return generateBase(map, fileName, options, definitions ?? {}, true);
+    return generateBase(map, fileName, definitions ?? {}, true);
   }
 
   @override
-  String generateResponses(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
+  String generateResponses(Map<String, dynamic> map, String fileName) {
     return '';
   }
 
   @override
-  String generateRequestBodies(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
+  String generateRequestBodies(Map<String, dynamic> map, String fileName) {
     return '';
   }
 
   @override
   List<String> getAllListEnumNames(Map<String, dynamic> map) {
-    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
+    final results = getEnumNamesFromRequests(map);
 
     final definitions = map['definitions'] as Map<String, dynamic>?;
 
@@ -36,8 +34,7 @@ class SwaggerModelsGeneratorV2 extends SwaggerModelsGenerator {
         if (mapMap['type'] == 'array' &&
             mapMap['items'] != null &&
             mapMap['items']['enum'] != null) {
-          results.add(SwaggerModelsGenerator.getValidatedClassName(
-              className.capitalize));
+          results.add(getValidatedClassName(className.capitalize));
           return;
         }
       });
diff --git a/lib/src/code_generators/v3/swagger_enums_generator_v3.dart b/lib/src/code_generators/v3/swagger_enums_generator_v3.dart
index 71b32c7e..fd04f60d 100644
--- a/lib/src/code_generators/v3/swagger_enums_generator_v3.dart
+++ b/lib/src/code_generators/v3/swagger_enums_generator_v3.dart
@@ -1,9 +1,15 @@
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_enums_generator.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_models_generator.dart';
+import 'package:swagger_dart_code_generator/src/code_generators/v2/swagger_models_generator_v2.dart';
+import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 
 class SwaggerEnumsGeneratorV3 extends SwaggerEnumsGenerator {
+  SwaggerEnumsGeneratorV3(GeneratorOptions options) : super(options);
+
   @override
-  String generate(Map<String, dynamic> map, String fileName) {
+  String generate(
+    Map<String, dynamic> map,
+    String fileName,
+  ) {
     final components = map['components'] as Map<String, dynamic>?;
     final schemas = components == null
         ? null
@@ -17,8 +23,8 @@ class SwaggerEnumsGeneratorV3 extends SwaggerEnumsGenerator {
         ? <String, dynamic>{}
         : components['requestBodies'] as Map<String, dynamic>? ?? {};
 
-    requestBodies
-        .addAll(SwaggerModelsGenerator.getRequestBodiesFromRequests(map));
+    requestBodies.addAll(
+        SwaggerModelsGeneratorV2(options).getRequestBodiesFromRequests(map));
 
     return generateFromMap(
       map,
diff --git a/lib/src/code_generators/v3/swagger_models_generator_v3.dart b/lib/src/code_generators/v3/swagger_models_generator_v3.dart
index 1cbe21ab..04b0bd3d 100644
--- a/lib/src/code_generators/v3/swagger_models_generator_v3.dart
+++ b/lib/src/code_generators/v3/swagger_models_generator_v3.dart
@@ -1,26 +1,25 @@
 import 'package:recase/recase.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/constants.dart';
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_enums_generator.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_models_generator.dart';
 import 'package:swagger_dart_code_generator/src/extensions/string_extension.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 import 'package:collection/collection.dart';
 
 class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
+  SwaggerModelsGeneratorV3(GeneratorOptions options) : super(options);
+
   @override
-  String generate(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
+  String generate(Map<String, dynamic> map, String fileName) {
     final components = map['components'] as Map<String, dynamic>?;
     final schemas = components == null
         ? null
         : components['schemas'] as Map<String, dynamic>?;
 
-    return generateBase(map, fileName, options, schemas ?? {}, true);
+    return generateBase(map, fileName, schemas ?? {}, true);
   }
 
   @override
-  String generateResponses(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
+  String generateResponses(Map<String, dynamic> map, String fileName) {
     final components = map['components'] as Map<String, dynamic>?;
     final responses = components == null
         ? null
@@ -35,7 +34,7 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
     final allModelNames = components!.containsKey('schemas')
         ? (components['schemas'] as Map<String, dynamic>)
             .keys
-            .map((e) => SwaggerModelsGenerator.getValidatedClassName(e))
+            .map((e) => getValidatedClassName(e))
         : <String>[];
 
     for (var key in responses.keys) {
@@ -58,7 +57,7 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
       }
     }
 
-    return generateBase(map, fileName, options, result, false);
+    return generateBase(map, fileName, result, false);
   }
 
   Map<String, dynamic> _getRequestBodiesFromRequests(Map<String, dynamic> map) {
@@ -94,8 +93,7 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
                   final className =
                       '${pathKey.pascalCase}${requestKey.pascalCase}\$$kRequestBody';
 
-                  result[SwaggerModelsGenerator.getValidatedClassName(
-                      className)] = requestBody;
+                  result[getValidatedClassName(className)] = requestBody;
                 }
               }
             }
@@ -108,8 +106,7 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
   }
 
   @override
-  String generateRequestBodies(
-      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
+  String generateRequestBodies(Map<String, dynamic> map, String fileName) {
     final components = map['components'] as Map<String, dynamic>?;
     final requestBodies = components == null
         ? <String, dynamic>{}
@@ -127,7 +124,7 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
     final allModelNames = components!.containsKey('schemas')
         ? (components['schemas'] as Map<String, dynamic>)
             .keys
-            .map((e) => SwaggerModelsGenerator.getValidatedClassName(e))
+            .map((e) => getValidatedClassName(e))
         : <String>[];
 
     for (var key in requestBodies.keys) {
@@ -150,12 +147,12 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
       }
     }
 
-    return generateBase(map, fileName, options, result, false);
+    return generateBase(map, fileName, result, false);
   }
 
   @override
   List<String> getAllListEnumNames(Map<String, dynamic> map) {
-    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
+    final results = getEnumNamesFromRequests(map);
 
     final components = map['components'] as Map<String, dynamic>?;
 
@@ -170,8 +167,7 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
         if (mapMap['type'] == 'array' &&
             mapMap['items'] != null &&
             mapMap['items']['enum'] != null) {
-          results.add(SwaggerModelsGenerator.getValidatedClassName(
-              className.capitalize));
+          results.add(getValidatedClassName(className.capitalize));
           return;
         }
       });
@@ -193,7 +189,7 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
 
       final ref = refItem['\$ref'].toString().split('/').last;
 
-      final className = SwaggerModelsGenerator.getValidatedClassName(ref);
+      final className = getValidatedClassName(ref);
 
       return 'extends $className';
     }
diff --git a/lib/src/models/generator_options.dart b/lib/src/models/generator_options.dart
index acd46b87..62afb851 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.cutFromModelNames = '',
   });
 
   /// Build options from a JSON map.
@@ -67,6 +68,9 @@ class GeneratorOptions {
   @JsonKey(defaultValue: false)
   final bool useDefaultNullForLists;
 
+  @JsonKey(defaultValue: '')
+  final String cutFromModelNames;
+
   @JsonKey(defaultValue: false)
   final bool buildOnlyModels;
 
diff --git a/lib/src/models/generator_options.g2.dart b/lib/src/models/generator_options.g2.dart
index 4dbc4a34..b41d9b6d 100644
--- a/lib/src/models/generator_options.g2.dart
+++ b/lib/src/models/generator_options.g2.dart
@@ -52,6 +52,7 @@ GeneratorOptions _$GeneratorOptionsFromJson(Map json) => GeneratorOptions(
               ?.map((e) => e as String)
               .toList() ??
           [],
+      cutFromModelNames: json['cut_from_model_names'] as String? ?? '',
     );
 
 Map<String, dynamic> _$GeneratorOptionsToJson(GeneratorOptions instance) =>
@@ -69,6 +70,7 @@ Map<String, dynamic> _$GeneratorOptionsToJson(GeneratorOptions instance) =>
       'input_folder': instance.inputFolder,
       'output_folder': instance.outputFolder,
       'use_default_null_for_lists': instance.useDefaultNullForLists,
+      'cut_from_model_names': instance.cutFromModelNames,
       'build_only_models': instance.buildOnlyModels,
       'model_postfix': instance.modelPostfix,
       'default_values_map': instance.defaultValuesMap,
diff --git a/lib/src/swagger_code_generator.dart b/lib/src/swagger_code_generator.dart
index a894c318..1624a55d 100644
--- a/lib/src/swagger_code_generator.dart
+++ b/lib/src/swagger_code_generator.dart
@@ -9,28 +9,31 @@ import 'package:swagger_dart_code_generator/src/code_generators/v3/swagger_model
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 
 class SwaggerCodeGenerator {
-  final Map<int, SwaggerEnumsGenerator> _enumsMap =
-      <int, SwaggerEnumsGenerator>{
-    2: SwaggerEnumsGeneratorV2(),
-    3: SwaggerEnumsGeneratorV3()
-  };
-
-  final Map<int, SwaggerModelsGenerator> _modelsMap =
-      <int, SwaggerModelsGenerator>{
-    2: SwaggerModelsGeneratorV2(),
-    3: SwaggerModelsGeneratorV3()
-  };
+  Map<int, SwaggerEnumsGenerator> _getEnumsMap(GeneratorOptions options) {
+    return <int, SwaggerEnumsGenerator>{
+      2: SwaggerEnumsGeneratorV2(options),
+      3: SwaggerEnumsGeneratorV3(options)
+    };
+  }
+
+  Map<int, SwaggerModelsGenerator> _getModelsMap(GeneratorOptions options) {
+    return <int, SwaggerModelsGenerator>{
+      2: SwaggerModelsGeneratorV2(options),
+      3: SwaggerModelsGeneratorV3(options)
+    };
+  }
 
   int _getApiVersion(Map map) {
     final openApi = map['openapi'] as String?;
     return openApi != null ? 3 : 2;
   }
 
-  String generateIndexes(List<String> fileNames) =>
-      _getSwaggerAdditionsGenerator().generateIndexes(fileNames);
+  String generateIndexes(List<String> fileNames, GeneratorOptions options) =>
+      _getSwaggerAdditionsGenerator(options).generateIndexes(fileNames);
 
-  String generateConverterMappings(bool hasModels) =>
-      _getSwaggerAdditionsGenerator().generateConverterMappings(hasModels);
+  String generateConverterMappings(bool hasModels, GeneratorOptions options) =>
+      _getSwaggerAdditionsGenerator(options)
+          .generateConverterMappings(hasModels);
 
   String generateImportsContent(
     String swaggerFileName,
@@ -38,59 +41,77 @@ class SwaggerCodeGenerator {
     bool buildOnlyModels,
     bool hasEnums,
     bool separateModels,
+    GeneratorOptions options,
   ) =>
-      _getSwaggerAdditionsGenerator().generateImportsContent(swaggerFileName,
-          hasModels, buildOnlyModels, hasEnums, separateModels);
+      _getSwaggerAdditionsGenerator(options).generateImportsContent(
+          swaggerFileName,
+          hasModels,
+          buildOnlyModels,
+          hasEnums,
+          separateModels);
 
   String generateResponses(
     Map<String, dynamic> map,
     String fileName,
     GeneratorOptions options,
   ) =>
-      _getSwaggerModelsGenerator(map).generateResponses(map, fileName, options);
+      _getSwaggerModelsGenerator(map, options).generateResponses(map, fileName);
 
   String generateRequestBodies(
     Map<String, dynamic> map,
     String fileName,
     GeneratorOptions options,
   ) =>
-      _getSwaggerModelsGenerator(map)
-          .generateRequestBodies(map, fileName, options);
+      _getSwaggerModelsGenerator(map, options)
+          .generateRequestBodies(map, fileName);
 
-  String generateEnums(Map<String, dynamic> map, String fileName) =>
-      _getSwaggerEnumsGenerator(map).generate(map, fileName);
+  String generateEnums(
+    Map<String, dynamic> map,
+    String fileName,
+    GeneratorOptions options,
+  ) =>
+      _getSwaggerEnumsGenerator(map, options).generate(map, fileName);
 
   String generateModels(Map<String, dynamic> dartCode, String fileName,
           GeneratorOptions options) =>
-      _getSwaggerModelsGenerator(dartCode)
-          .generate(dartCode, fileName, options);
+      _getSwaggerModelsGenerator(dartCode, options)
+          .generate(dartCode, fileName);
 
   String generateRequests(Map<String, dynamic> map, String className,
           String fileName, GeneratorOptions options) =>
-      _getSwaggerRequestsGenerator(map).generate(
+      _getSwaggerRequestsGenerator(map, options).generate(
         map: map,
         className: className,
         fileName: fileName,
-        options: options,
       );
 
   String generateCustomJsonConverter(
           String fileName, GeneratorOptions options) =>
-      _getSwaggerAdditionsGenerator()
-          .generateCustomJsonConverter(fileName, options);
+      _getSwaggerAdditionsGenerator(options)
+          .generateCustomJsonConverter(fileName);
 
-  String generateDateToJson() =>
-      _getSwaggerAdditionsGenerator().generateDateToJson();
+  String generateDateToJson(GeneratorOptions options) =>
+      _getSwaggerAdditionsGenerator(options).generateDateToJson();
 
-  SwaggerAdditionsGenerator _getSwaggerAdditionsGenerator() =>
-      SwaggerAdditionsGenerator();
+  SwaggerAdditionsGenerator _getSwaggerAdditionsGenerator(
+          GeneratorOptions options) =>
+      SwaggerAdditionsGenerator(options);
 
-  SwaggerEnumsGenerator _getSwaggerEnumsGenerator(Map root) =>
-      _enumsMap[_getApiVersion(root)]!;
+  SwaggerEnumsGenerator _getSwaggerEnumsGenerator(
+    Map root,
+    GeneratorOptions options,
+  ) =>
+      _getEnumsMap(options)[_getApiVersion(root)]!;
 
-  SwaggerModelsGenerator _getSwaggerModelsGenerator(Map root) =>
-      _modelsMap[_getApiVersion(root)]!;
+  SwaggerModelsGenerator _getSwaggerModelsGenerator(
+    Map root,
+    GeneratorOptions options,
+  ) =>
+      _getModelsMap(options)[_getApiVersion(root)]!;
 
-  SwaggerRequestsGenerator _getSwaggerRequestsGenerator(Map root) =>
-      SwaggerRequestsGenerator();
+  SwaggerRequestsGenerator _getSwaggerRequestsGenerator(
+    Map root,
+    GeneratorOptions options,
+  ) =>
+      SwaggerRequestsGenerator(options);
 }
diff --git a/lib/swagger_dart_code_generator.dart b/lib/swagger_dart_code_generator.dart
index b375e7a4..0be2ebcc 100644
--- a/lib/swagger_dart_code_generator.dart
+++ b/lib/swagger_dart_code_generator.dart
@@ -182,7 +182,7 @@ class SwaggerDartCodeGenerator implements Builder {
         contents, removeFileExtension(fileNameWithExtension), options);
 
     final enums = codeGenerator.generateEnums(
-        contents, removeFileExtension(fileNameWithExtension));
+        contents, removeFileExtension(fileNameWithExtension), options);
 
     final imports = codeGenerator.generateImportsContent(
       fileNameWithoutExtension,
@@ -190,6 +190,7 @@ class SwaggerDartCodeGenerator implements Builder {
       options.buildOnlyModels,
       enums.isNotEmpty,
       options.separateModels,
+      options,
     );
 
     final requests = codeGenerator.generateRequests(
@@ -201,7 +202,7 @@ class SwaggerDartCodeGenerator implements Builder {
     final customDecoder = codeGenerator.generateCustomJsonConverter(
         removeFileExtension(fileNameWithExtension), options);
 
-    final dateToJson = codeGenerator.generateDateToJson();
+    final dateToJson = codeGenerator.generateDateToJson(options);
 
     final copyAssetId = AssetId(
         buildStep.inputId.package,
@@ -299,7 +300,7 @@ $dateToJson
     final indexAssetId =
         AssetId(inputId.package, join(options.outputFolder, _indexFileName));
 
-    final imports = codeGenerator.generateIndexes(allFiles);
+    final imports = codeGenerator.generateIndexes(allFiles, options);
 
     if (!options.buildOnlyModels) {
       await buildStep.writeAsString(indexAssetId, _formatter.format(imports));
@@ -309,7 +310,8 @@ $dateToJson
       final mappingAssetId = AssetId(
           inputId.package, join(options.outputFolder, _mappingFileName));
 
-      final mapping = codeGenerator.generateConverterMappings(hasModels);
+      final mapping =
+          codeGenerator.generateConverterMappings(hasModels, options);
 
       await buildStep.writeAsString(mappingAssetId, _formatter.format(mapping));
     }
diff --git a/pubspec.yaml b/pubspec.yaml
index 49e99ccf..239c5fa3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
 name: swagger_dart_code_generator
 
-version: 2.4.5
+version: 2.4.6
 
 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/additions_generator_test.dart b/test/generator_tests/additions_generator_test.dart
index f3a76391..4286b9dc 100644
--- a/test/generator_tests/additions_generator_test.dart
+++ b/test/generator_tests/additions_generator_test.dart
@@ -1,9 +1,15 @@
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_additions_generator.dart';
+import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 import 'package:test/test.dart';
 
 void main() {
   group('Additions generator tests', () {
-    final generator = SwaggerAdditionsGenerator();
+    final generator = SwaggerAdditionsGenerator(
+      GeneratorOptions(
+        inputFolder: '',
+        outputFolder: '',
+      ),
+    );
 
     test('Should generate correct imports', () {
       final result = generator.generateImportsContent(
@@ -32,7 +38,12 @@ void main() {
     });
   });
   group('Test for generateDateToJson', () {
-    final generator = SwaggerAdditionsGenerator();
+    final generator = SwaggerAdditionsGenerator(
+      GeneratorOptions(
+        inputFolder: '',
+        outputFolder: '',
+      ),
+    );
     test('Should dateToJson with parameter', () {
       const expectedResult = 'String? _dateToJson(DateTime? date)';
       final result = generator.generateDateToJson();
diff --git a/test/generator_tests/enums_generator_test.dart b/test/generator_tests/enums_generator_test.dart
index f72627e7..97e7926f 100644
--- a/test/generator_tests/enums_generator_test.dart
+++ b/test/generator_tests/enums_generator_test.dart
@@ -3,12 +3,18 @@ import 'dart:convert';
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_enums_generator.dart';
 //import 'package:swagger_dart_code_generator/src/code_generators/v2/swagger_enums_generator_v2.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/v3/swagger_enums_generator_v3.dart';
+import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 import 'package:swagger_dart_code_generator/src/swagger_models/requests/swagger_request_parameter.dart';
 import 'package:test/test.dart';
 import '../code_examples.dart';
 
 void main() {
-  final generator = SwaggerEnumsGeneratorV3();
+  final generator = SwaggerEnumsGeneratorV3(
+    GeneratorOptions(
+      inputFolder: '',
+      outputFolder: '',
+    ),
+  );
   //final generatorv2 = SwaggerEnumsGeneratorV2();
 
   group('Generate', () {
@@ -74,20 +80,25 @@ void main() {
 
     test('Should remove numbers at beginning if it is key word', () {
       final map = jsonDecode(requestWithEnum) as Map<String, dynamic>;
-      final result = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
+      final result = generator.getEnumNamesFromRequests(map);
       expect(result[0], equals('PetsPetIdItemsGetContentType'));
     });
 
     test('Should remove numbers at beginning if it is key word', () {
       final map =
           jsonDecode(requestWithListOfEnumInParameter) as Map<String, dynamic>;
-      final result = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
+      final result = generator.getEnumNamesFromRequests(map);
       expect(result[0], equals('V3OrderOrderIdStatePutOrderStateRequest'));
     });
   });
 
   group('generateEnumContentIfPossible', () {
-    final generator = SwaggerEnumsGeneratorV3();
+    final generator = SwaggerEnumsGeneratorV3(
+      GeneratorOptions(
+        inputFolder: '',
+        outputFolder: '',
+      ),
+    );
     test('Should generate enum', () {
       final map = <String, dynamic>{
         'items': {
@@ -102,7 +113,12 @@ void main() {
   });
 
   group('generateEnumName', () {
-    final generator = SwaggerEnumsGeneratorV3();
+    final generator = SwaggerEnumsGeneratorV3(
+      GeneratorOptions(
+        inputFolder: '',
+        outputFolder: '',
+      ),
+    );
 
     test('Should generate enum name', () {
       const className = 'animal';
@@ -123,9 +139,8 @@ void main() {
             name: 'TestParameter', type: 'Overridden parameter')
       ];
 
-      final result =
-          SwaggerEnumsGenerator.getOriginalOrOverriddenRequestParameter(
-              incoming, overriddenParameters);
+      final result = generator.getOriginalOrOverriddenRequestParameter(
+          incoming, overriddenParameters);
 
       expect(result.type, equals('Overridden parameter'));
     });
@@ -138,9 +153,8 @@ void main() {
             key: 'TestParameter', name: 'Overridden parameter')
       ];
 
-      final result =
-          SwaggerEnumsGenerator.getOriginalOrOverriddenRequestParameter(
-              incoming, overriddenParameters);
+      final result = generator.getOriginalOrOverriddenRequestParameter(
+          incoming, overriddenParameters);
 
       expect(result.name, equals('Original parameter'));
     });
diff --git a/test/generator_tests/models_generator_test.dart b/test/generator_tests/models_generator_test.dart
index 01675a8b..6a7a79a3 100644
--- a/test/generator_tests/models_generator_test.dart
+++ b/test/generator_tests/models_generator_test.dart
@@ -1,6 +1,5 @@
 import 'dart:convert';
 
-import 'package:swagger_dart_code_generator/src/code_generators/swagger_models_generator.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/v2/swagger_models_generator_v2.dart';
 import 'package:swagger_dart_code_generator/src/code_generators/v3/swagger_models_generator_v3.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
@@ -8,15 +7,24 @@ import 'package:test/test.dart';
 import '../code_examples.dart';
 
 void main() {
-  final generator = SwaggerModelsGeneratorV3();
-  final generator2 = SwaggerModelsGeneratorV2();
+  final generator = SwaggerModelsGeneratorV3(
+    GeneratorOptions(
+      inputFolder: '',
+      outputFolder: '',
+    ),
+  );
+  final generator2 = SwaggerModelsGeneratorV2(
+    GeneratorOptions(
+      inputFolder: '',
+      outputFolder: '',
+    ),
+  );
   group('generate', () {
     const fileName = 'order_service.dart';
 
     test('Should parse object name as a field Type', () {
       final map = jsonDecode(modelWithParametersV3) as Map<String, dynamic>;
-      final result = generator.generate(
-          map, fileName, GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final result = generator.generate(map, fileName);
 
       expect(
           result, contains('final enums.TokensResponseTokenType? tokenType'));
@@ -24,11 +32,11 @@ void main() {
 
     test('Should generate .toLower() when caseSensitive: false', () {
       final map = jsonDecode(modelWithParametersV3) as Map<String, dynamic>;
-      final result = generator.generate(
-          map,
-          fileName,
-          GeneratorOptions(
-              enumsCaseSensitive: false, inputFolder: '', outputFolder: ''));
+      final result = SwaggerModelsGeneratorV3(GeneratorOptions(
+        inputFolder: '',
+        outputFolder: '',
+        enumsCaseSensitive: false,
+      )).generate(map, fileName);
 
       expect(
           result,
@@ -38,19 +46,14 @@ void main() {
 
     test('Should NOT generate .toLower() when caseSensitive: false', () {
       final map = jsonDecode(modelWithParametersV3) as Map<String, dynamic>;
-      final result = generator.generate(
-          map,
-          fileName,
-          GeneratorOptions(
-              enumsCaseSensitive: true, inputFolder: '', outputFolder: ''));
+      final result = generator.generate(map, fileName);
 
       expect(result, contains('element.value == someEnumModel'));
     });
 
     test('Should parse object name as a field Type', () {
       final map = jsonDecode(modelWithParametersV2) as Map<String, dynamic>;
-      final result = generator2.generate(
-          map, fileName, GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final result = generator2.generate(map, fileName);
 
       expect(
           result,
@@ -61,17 +64,18 @@ void main() {
     test('Should parse object name as a field Type', () {
       const expectedResult = "@JsonKey(name: 'expires_in', defaultValue: 19)";
       final map = jsonDecode(modelWithParametersV3) as Map<String, dynamic>;
-      final generatorOptions = GeneratorOptions(
-        defaultValuesMap: <DefaultValueMap>[
-          DefaultValueMap(
-            typeName: 'int',
-            defaultValue: '19',
-          )
-        ],
-        inputFolder: '',
-        outputFolder: '',
-      );
-      final result = generator.generate(map, fileName, generatorOptions);
+      final result = SwaggerModelsGeneratorV3(
+        GeneratorOptions(
+          inputFolder: '',
+          outputFolder: '',
+          defaultValuesMap: [
+            DefaultValueMap(
+              typeName: 'int',
+              defaultValue: '19',
+            ),
+          ],
+        ),
+      ).generate(map, fileName);
 
       expect(result, contains(expectedResult));
     });
@@ -184,7 +188,7 @@ void main() {
     test('Should return validate field name', () {
       const name = 'Cat_Dog-Animals';
       const expectedResult = 'catDogAnimals';
-      final result = SwaggerModelsGenerator.generateFieldName(name);
+      final result = generator.generateFieldName(name);
 
       expect(result, contains(expectedResult));
     });
@@ -192,7 +196,7 @@ void main() {
     test('Should return \$forbiddenFieldName', () {
       const name = '#';
       const expectedResult = '\$forbiddenFieldName';
-      final result = SwaggerModelsGenerator.generateFieldName(name);
+      final result = generator.generateFieldName(name);
 
       expect(result, contains(expectedResult));
     });
@@ -200,7 +204,7 @@ void main() {
     test('Should return \$null', () {
       const name = 'null';
       const expectedResult = '\$null';
-      final result = SwaggerModelsGenerator.generateFieldName(name);
+      final result = generator.generateFieldName(name);
 
       expect(result, contains(expectedResult));
     });
@@ -208,7 +212,7 @@ void main() {
     test('Should return \$number', () {
       const name = '5element';
       const expectedResult = '\$5element';
-      final result = SwaggerModelsGenerator.generateFieldName(name);
+      final result = generator.generateFieldName(name);
 
       expect(result, contains(expectedResult));
     });
@@ -220,11 +224,11 @@ void main() {
       const propertyName = 'shipDate';
       const jsonKeyExpendedResult = "@JsonKey(name: '$propertyName'";
       final result = generator.generatePropertyContentByDefault(
-          propertyEntryMap,
-          propertyName,
-          [],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        propertyEntryMap,
+        propertyName,
+        [],
+        [],
+      );
 
       expect(result, contains(jsonKeyExpendedResult));
     });
@@ -232,13 +236,16 @@ void main() {
     test('Should generate includeIfNull if option is true', () {
       final propertyEntryMap = <String, dynamic>{'originalRef': 'Pet'};
       const propertyName = 'shipDate';
-      final result = generator.generatePropertyContentByDefault(
-          propertyEntryMap,
-          propertyName,
-          [],
-          [],
-          GeneratorOptions(
-              includeIfNull: false, inputFolder: '', outputFolder: ''));
+      final result = SwaggerModelsGeneratorV3(GeneratorOptions(
+        inputFolder: '',
+        outputFolder: '',
+        includeIfNull: false,
+      )).generatePropertyContentByDefault(
+        propertyEntryMap,
+        propertyName,
+        [],
+        [],
+      );
 
       expect(result, contains(', includeIfNull: false'));
     });
@@ -247,12 +254,11 @@ void main() {
       final propertyEntryMap = <String, dynamic>{'originalRef': 'Pet'};
       const propertyName = 'shipDate';
       final result = generator.generatePropertyContentByDefault(
-          propertyEntryMap,
-          propertyName,
-          [],
-          [],
-          GeneratorOptions(
-              includeIfNull: null, inputFolder: '', outputFolder: ''));
+        propertyEntryMap,
+        propertyName,
+        [],
+        [],
+      );
 
       expect(result.contains(', includeIfNull: false'), equals(false));
     });
@@ -275,7 +281,6 @@ void main() {
         className,
         [],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -296,7 +301,6 @@ void main() {
         className,
         ['enums.Pet'],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -312,8 +316,12 @@ void main() {
       const jsonKeyExpectedResult =
           'toJson: animalsDogToJson, fromJson: animalsDogFromJson';
       const expectedResult = 'final AnimalsDog? dog;';
-      final result = generator.generateEnumPropertyContent(key, className, [],
-          [], GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final result = generator.generateEnumPropertyContent(
+        key,
+        className,
+        [],
+        [],
+      );
 
       expect(result, contains(jsonKeyExpectedResult));
       expect(result, contains(expectedResult));
@@ -329,15 +337,15 @@ void main() {
       const factoryConstructorExpectedResult =
           '\tfactory Animals.fromJson(Map<String, dynamic> json) => _\$AnimalsFromJson(json);\n';
       final result = generator.generateModelClassContent(
-          {},
-          className,
-          map,
-          {},
-          <DefaultValueMap>[],
-          useDefaultNullForLists,
-          [],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        {},
+        className,
+        map,
+        {},
+        <DefaultValueMap>[],
+        useDefaultNullForLists,
+        [],
+        [],
+      );
 
       expect(result, contains(classExpectedResult));
       expect(result, contains(factoryConstructorExpectedResult));
@@ -351,15 +359,15 @@ void main() {
       const factoryConstructorExpectedResult =
           '\tfactory Animals.fromJson(Map<String, dynamic> json) => _\$AnimalsFromJson(json);\n';
       final result = generator2.generateModelClassContent(
-          {},
-          className,
-          map,
-          {},
-          <DefaultValueMap>[],
-          useDefaultNullForLists,
-          [],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        {},
+        className,
+        map,
+        {},
+        <DefaultValueMap>[],
+        useDefaultNullForLists,
+        [],
+        [],
+      );
 
       expect(result, contains(classExpectedResult));
       expect(result, contains(factoryConstructorExpectedResult));
@@ -372,7 +380,6 @@ void main() {
       final result = generator.generateConstructorPropertiesContent(
         '',
         {},
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         [],
         [],
         [],
@@ -389,7 +396,6 @@ void main() {
       final result = generator.generateConstructorPropertiesContent(
         '',
         map,
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         [],
         [],
         [],
@@ -416,7 +422,6 @@ void main() {
         className,
         [],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -439,7 +444,6 @@ void main() {
         className,
         ['enums.Pet'],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -457,15 +461,15 @@ void main() {
       const jsonKeyExpectedResult = "\t@JsonKey(name: 'Animals')\n";
       const fieldExpectedResult = 'final Pet? animals';
       final result = generator.generatePropertiesContent(
-          map,
-          map,
-          {},
-          className,
-          <DefaultValueMap>[],
-          false,
-          [],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        map,
+        map,
+        {},
+        className,
+        <DefaultValueMap>[],
+        false,
+        [],
+        [],
+      );
 
       expect(result, contains(jsonKeyExpectedResult));
       expect(result, contains(fieldExpectedResult));
@@ -482,15 +486,15 @@ void main() {
       const jsonKeyExpectedResult = "\t@JsonKey(name: 'Animals')\n";
       const fieldExpectedResult = 'final Pet? animals';
       final result = generator.generatePropertiesContent(
-          map,
-          map,
-          {},
-          className,
-          <DefaultValueMap>[],
-          false,
-          [],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        map,
+        map,
+        {},
+        className,
+        <DefaultValueMap>[],
+        false,
+        [],
+        [],
+      );
 
       expect(result, contains(jsonKeyExpectedResult));
       expect(result, contains(fieldExpectedResult));
@@ -505,15 +509,15 @@ void main() {
       const jsonKeyExpectedResult = "\t@JsonKey(name: 'animals')\n";
       const fieldExpectedResult = 'final Pet? animals';
       final result = generator.generatePropertiesContent(
-          map,
-          map,
-          {},
-          className,
-          <DefaultValueMap>[],
-          false,
-          [],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        map,
+        map,
+        {},
+        className,
+        <DefaultValueMap>[],
+        false,
+        [],
+        [],
+      );
 
       expect(result, contains(jsonKeyExpectedResult));
       expect(result, contains(fieldExpectedResult));
@@ -528,15 +532,15 @@ void main() {
       const jsonKeyExpectedResult = "\t@JsonKey(name: '\$with')\n";
       const fieldExpectedResult = 'final Pet? \$with';
       final result = generator.generatePropertiesContent(
-          map,
-          map,
-          {},
-          className,
-          <DefaultValueMap>[],
-          false,
-          [],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        map,
+        map,
+        {},
+        className,
+        <DefaultValueMap>[],
+        false,
+        [],
+        [],
+      );
 
       expect(result, contains(jsonKeyExpectedResult));
       expect(result, contains(fieldExpectedResult));
@@ -561,7 +565,6 @@ void main() {
         false,
         [],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -584,7 +587,6 @@ void main() {
         false,
         ['Dog'],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -608,7 +610,6 @@ void main() {
         false,
         [],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -631,7 +632,6 @@ void main() {
         false,
         [],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -654,7 +654,6 @@ void main() {
         false,
         [],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -677,7 +676,6 @@ void main() {
         false,
         [],
         [],
-        GeneratorOptions(inputFolder: '', outputFolder: ''),
         {},
       );
 
@@ -687,7 +685,7 @@ void main() {
 
   group('Tests for getValidatedClassName', () {
     test('Should', () {
-      final result = SwaggerModelsGenerator.getValidatedClassName('Request');
+      final result = generator.getValidatedClassName('Request');
 
       expect(result, equals('Request\$'));
     });
@@ -696,14 +694,14 @@ void main() {
   group('Tests for generateGeneralPropertyContent', () {
     test('Should', () {
       final result = generator.generateGeneralPropertyContent(
-          'name',
-          'key',
-          'className',
-          [],
-          {'\$ref': 'ClassNameName'},
-          ['enums.ClassNameName'],
-          [],
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+        'name',
+        'key',
+        'className',
+        [],
+        {'\$ref': 'ClassNameName'},
+        ['enums.ClassNameName'],
+        [],
+      );
 
       expect(result, contains('final enums.ClassNameName? name;'));
     });
@@ -713,13 +711,7 @@ void main() {
     test('Should generate empty string for V2', () {
       final map =
           jsonDecode(schemasResponsesWithResponse) as Map<String, dynamic>;
-      final result = generator2.generateResponses(
-          map,
-          'fileName',
-          GeneratorOptions(
-            inputFolder: '',
-            outputFolder: '',
-          ));
+      final result = generator2.generateResponses(map, 'fileName');
 
       expect(result, equals(''));
     });
@@ -727,8 +719,7 @@ void main() {
     test('Should generate class from responses V3', () {
       final map =
           jsonDecode(schemasResponsesWithResponse) as Map<String, dynamic>;
-      final result = generator.generateResponses(
-          map, 'fileName', GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final result = generator.generateResponses(map, 'fileName');
 
       expect(result, contains('class SpaResponse'));
     });
@@ -736,13 +727,7 @@ void main() {
     test('Should generate class from responses V3 and Schemas', () {
       final map = jsonDecode(schemasResponsesWithResponseAndSchemas)
           as Map<String, dynamic>;
-      final result = generator.generateResponses(
-          map,
-          'fileName',
-          GeneratorOptions(
-            inputFolder: '',
-            outputFolder: '',
-          ));
+      final result = generator.generateResponses(map, 'fileName');
 
       expect(result, contains('class SpaResponse'));
     });
@@ -784,13 +769,7 @@ void main() {
     test('Should generate correct model from response', () {
       final map =
           jsonDecode(requestWithReturnTypeInjected) as Map<String, dynamic>;
-      final result = generator.generate(
-          map,
-          'my_service',
-          GeneratorOptions(
-            inputFolder: '',
-            outputFolder: '',
-          ));
+      final result = generator.generate(map, 'my_service');
 
       expect(result, contains('class ModelItemsGet\$Response'));
     });
diff --git a/test/generator_tests/requests_generator_test.dart b/test/generator_tests/requests_generator_test.dart
index 157d2a1a..ac852e97 100644
--- a/test/generator_tests/requests_generator_test.dart
+++ b/test/generator_tests/requests_generator_test.dart
@@ -8,45 +8,41 @@ import 'test_data.dart';
 
 void main() {
   group('Additions generator tests', () {
-    final generator = SwaggerRequestsGenerator();
-
     final map = jsonDecode(carsService) as Map<String, dynamic>;
 
     test('Should generate CarsApi', () {
-      final result = generator.generate(
+      final result = SwaggerRequestsGenerator(GeneratorOptions(
+        inputFolder: '',
+        outputFolder: '',
+        ignoreHeaders: true,
+        responseOverrideValueMap: [
+          ResponseOverrideValueMap(
+            method: 'get',
+            url: '/cars/schemaRefBody',
+            overriddenValue: 'String',
+          )
+        ],
+      )).generate(
         map: map,
         className: 'CarsService',
         fileName: 'cars_service',
-        options: GeneratorOptions(
+      );
+
+      final result2 = SwaggerRequestsGenerator(GeneratorOptions(
           inputFolder: '',
           outputFolder: '',
-          ignoreHeaders: true,
-          responseOverrideValueMap: [
-            ResponseOverrideValueMap(
-              method: 'get',
-              url: '/cars/schemaRefBody',
-              overriddenValue: 'String',
-            )
+          defaultHeaderValuesMap: [
+            DefaultHeaderValueMap(
+              defaultValue: '120',
+              headerName: 'id',
+            ),
           ],
-        ),
-      );
-
-      final result2 = generator.generate(
+          includePaths: [
+            'car'
+          ])).generate(
         map: map,
         className: 'CarsService',
         fileName: 'cars_service',
-        options: GeneratorOptions(
-            inputFolder: '',
-            outputFolder: '',
-            defaultHeaderValuesMap: [
-              DefaultHeaderValueMap(
-                defaultValue: '120',
-                headerName: 'id',
-              ),
-            ],
-            includePaths: [
-              'car'
-            ]),
       );
 
       expect(result2, contains('Future<chopper.Response<CarModel>>'));