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

Issue:
[FEATURE] introduce built-in solution to automatically translate from YAML to JSON
**Is your feature request related to a problem? Please describe.**
Until we start supporting YAML we need to provide a built-in solution to transform YAML-based swagger to JSON and then generate.

**Describe the solution you'd like**
For MAC OS we can use BREW.




Fix patch:
diff --git a/example/build.yaml b/example/build.yaml
index ca3853da..53349b6b 100644
--- a/example/build.yaml
+++ b/example/build.yaml
@@ -4,6 +4,7 @@ targets:
       - lib/**
       - swaggers/**
       - swaggers2/**
+      - input_folder/**
       - swagger_examples/**
       - $package$
     builders:
@@ -12,11 +13,8 @@ targets:
           header: "//Generated code"
       swagger_dart_code_generator:
         options:
-          input_folder: "lib/"
+          input_folder: "input_folder/"
           output_folder: "lib/swagger_generated_code/"
-          use_inheritance: false
-          input_urls:
-            - "https://raw.githubusercontent.com/epam-cross-platform-lab/swagger-dart-code-generator/master/example/lib/example_swagger.json"
           with_base_url: true
           with_converter: true
           use_path_for_request_names: true
diff --git a/example/lib/pets_api.json b/example/input_folder/pet_service_json.json
similarity index 100%
rename from example/lib/pets_api.json
rename to example/input_folder/pet_service_json.json
diff --git a/example/input_folder/pet_service_yaml.yaml b/example/input_folder/pet_service_yaml.yaml
new file mode 100644
index 00000000..b7b343d3
--- /dev/null
+++ b/example/input_folder/pet_service_yaml.yaml
@@ -0,0 +1,700 @@
+swagger: '2.0'
+info:
+  description: 'This is a sample server Petstore server.  You can find out more about     Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).      For this sample, you can use the api key `special-key` to test the authorization     filters.'
+  version: 1.0.0
+  title: Swagger Petstore
+  termsOfService: http://swagger.io/terms/
+  contact:
+    email: apiteam@swagger.io
+  license:
+    name: Apache 2.0
+    url: http://www.apache.org/licenses/LICENSE-2.0.html
+host: petstore.swagger.io
+basePath: /v2
+tags:
+  - name: pet
+    description: Everything about your Pets
+    externalDocs:
+      description: Find out more
+      url: http://swagger.io
+  - name: store
+    description: Access to Petstore orders
+  - name: user
+    description: Operations about user
+    externalDocs:
+      description: Find out more about our store
+      url: http://swagger.io
+schemes:
+  - https
+  - http
+paths:
+  /pet:
+    post:
+      tags:
+        - pet
+      summary: Add a new pet to the store
+      description: ''
+      operationId: addPet
+      consumes:
+        - application/json
+        - application/xml
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - in: body
+          name: body
+          description: Pet object that needs to be added to the store
+          required: true
+          schema:
+            $ref: '#/definitions/Pet'
+      responses:
+        '405':
+          description: Invalid input
+      security:
+        - petstore_auth:
+            - write:pets
+            - read:pets
+    put:
+      tags:
+        - pet
+      summary: Update an existing pet
+      description: ''
+      operationId: updatePet
+      consumes:
+        - application/json
+        - application/xml
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - in: body
+          name: body
+          description: Pet object that needs to be added to the store
+          required: true
+          schema:
+            $ref: '#/definitions/Pet'
+      responses:
+        '400':
+          description: Invalid ID supplied
+        '404':
+          description: Pet not found
+        '405':
+          description: Validation exception
+      security:
+        - petstore_auth:
+            - write:pets
+            - read:pets
+  /pet/findByStatus:
+    get:
+      tags:
+        - pet
+      summary: Finds Pets by status
+      description: Multiple status values can be provided with comma separated strings
+      operationId: findPetsByStatus
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: status
+          in: query
+          description: Status values that need to be considered for filter
+          required: true
+          type: array
+          items:
+            type: string
+            enum:
+              - available
+              - pending
+              - sold
+            default: available
+          collectionFormat: multi
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            type: array
+            items:
+              $ref: '#/definitions/Pet'
+        '400':
+          description: Invalid status value
+      security:
+        - petstore_auth:
+            - write:pets
+            - read:pets
+  /pet/findByTags:
+    get:
+      tags:
+        - pet
+      summary: Finds Pets by tags
+      description: Muliple tags can be provided with comma separated strings. Use         tag1, tag2, tag3 for testing.
+      operationId: findPetsByTags
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: tags
+          in: query
+          description: Tags to filter by
+          required: true
+          type: array
+          items:
+            type: string
+          collectionFormat: multi
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            type: array
+            items:
+              $ref: '#/definitions/Pet'
+        '400':
+          description: Invalid tag value
+      security:
+        - petstore_auth:
+            - write:pets
+            - read:pets
+      deprecated: true
+  /pet/{petId}:
+    get:
+      tags:
+        - pet
+      summary: Find pet by ID
+      description: Returns a single pet
+      operationId: getPetById
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: petId
+          in: path
+          description: ID of pet to return
+          required: true
+          type: integer
+          format: int64
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            $ref: '#/definitions/Pet'
+        '400':
+          description: Invalid ID supplied
+        '404':
+          description: Pet not found
+      security:
+        - api_key: []
+    post:
+      tags:
+        - pet
+      summary: Updates a pet in the store with form data
+      description: ''
+      operationId: updatePetWithForm
+      consumes:
+        - application/x-www-form-urlencoded
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: petId
+          in: path
+          description: ID of pet that needs to be updated
+          required: true
+          type: integer
+          format: int64
+        - name: name
+          in: formData
+          description: Updated name of the pet
+          required: false
+          type: string
+        - name: status
+          in: formData
+          description: Updated status of the pet
+          required: false
+          type: string
+      responses:
+        '405':
+          description: Invalid input
+      security:
+        - petstore_auth:
+            - write:pets
+            - read:pets
+    delete:
+      tags:
+        - pet
+      summary: Deletes a pet
+      description: ''
+      operationId: deletePet
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: api_key
+          in: header
+          required: false
+          type: string
+        - name: petId
+          in: path
+          description: Pet id to delete
+          required: true
+          type: integer
+          format: int64
+      responses:
+        '400':
+          description: Invalid ID supplied
+        '404':
+          description: Pet not found
+      security:
+        - petstore_auth:
+            - write:pets
+            - read:pets
+  /pet/{petId}/uploadImage:
+    post:
+      tags:
+        - pet
+      summary: uploads an image
+      description: ''
+      operationId: uploadFile
+      consumes:
+        - multipart/form-data
+      produces:
+        - application/json
+      parameters:
+        - name: petId
+          in: path
+          description: ID of pet to update
+          required: true
+          type: integer
+          format: int64
+        - name: additionalMetadata
+          in: formData
+          description: Additional data to pass to server
+          required: false
+          type: string
+        - name: file
+          in: formData
+          description: file to upload
+          required: false
+          type: file
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            $ref: '#/definitions/ApiResponse'
+      security:
+        - petstore_auth:
+            - write:pets
+            - read:pets
+  /store/inventory:
+    get:
+      tags:
+        - store
+      summary: Returns pet inventories by status
+      description: Returns a map of status codes to quantities
+      operationId: getInventory
+      produces:
+        - application/json
+      parameters: []
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            type: object
+            additionalProperties:
+              type: integer
+              format: int32
+      security:
+        - api_key: []
+  /store/order:
+    post:
+      tags:
+        - store
+      summary: Place an order for a pet
+      description: ''
+      operationId: placeOrder
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - in: body
+          name: body
+          description: order placed for purchasing the pet
+          required: true
+          schema:
+            $ref: '#/definitions/Order'
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            $ref: '#/definitions/Order'
+        '400':
+          description: Invalid Order
+  /store/order/{orderId}:
+    get:
+      tags:
+        - store
+      summary: Find purchase order by ID
+      description: For valid response try integer IDs with value >= 1 and <= 10.         Other values will generated exceptions
+      operationId: getOrderById
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: orderId
+          in: path
+          description: ID of pet that needs to be fetched
+          required: true
+          type: integer
+          maximum: 10
+          minimum: 1
+          format: int64
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            $ref: '#/definitions/Order'
+        '400':
+          description: Invalid ID supplied
+        '404':
+          description: Order not found
+    delete:
+      tags:
+        - store
+      summary: Delete purchase order by ID
+      description: For valid response try integer IDs with positive integer value.         Negative or non-integer values will generate API errors
+      operationId: deleteOrder
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: orderId
+          in: path
+          description: ID of the order that needs to be deleted
+          required: true
+          type: integer
+          minimum: 1
+          format: int64
+      responses:
+        '400':
+          description: Invalid ID supplied
+        '404':
+          description: Order not found
+  /user:
+    post:
+      tags:
+        - user
+      summary: Create user
+      description: This can only be done by the logged in user.
+      operationId: createUser
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - in: body
+          name: body
+          description: Created user object
+          required: true
+          schema:
+            $ref: '#/definitions/User'
+      responses:
+        default:
+          description: successful operation
+  /user/createWithArray:
+    post:
+      tags:
+        - user
+      summary: Creates list of users with given input array
+      description: ''
+      operationId: createUsersWithArrayInput
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - in: body
+          name: body
+          description: List of user object
+          required: true
+          schema:
+            type: array
+            items:
+              $ref: '#/definitions/User'
+      responses:
+        default:
+          description: successful operation
+  /user/createWithList:
+    post:
+      tags:
+        - user
+      summary: Creates list of users with given input array
+      description: ''
+      operationId: createUsersWithListInput
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - in: body
+          name: body
+          description: List of user object
+          required: true
+          schema:
+            type: array
+            items:
+              $ref: '#/definitions/User'
+      responses:
+        default:
+          description: successful operation
+  /user/login:
+    get:
+      tags:
+        - user
+      summary: Logs user into the system
+      description: ''
+      operationId: loginUser
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: username
+          in: query
+          description: The user name for login
+          required: true
+          type: string
+        - name: password
+          in: query
+          description: The password for login in clear text
+          required: true
+          type: string
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            type: string
+          headers:
+            X-Rate-Limit:
+              type: integer
+              format: int32
+              description: calls per hour allowed by the user
+            X-Expires-After:
+              type: string
+              format: date-time
+              description: date in UTC when token expires
+        '400':
+          description: Invalid username/password supplied
+  /user/logout:
+    get:
+      tags:
+        - user
+      summary: Logs out current logged in user session
+      description: ''
+      operationId: logoutUser
+      produces:
+        - application/xml
+        - application/json
+      parameters: []
+      responses:
+        default:
+          description: successful operation
+  /user/{username}:
+    get:
+      tags:
+        - user
+      summary: Get user by user name
+      description: ''
+      operationId: getUserByName
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: username
+          in: path
+          description: 'The name that needs to be fetched. Use user1 for testing. '
+          required: true
+          type: string
+      responses:
+        '200':
+          description: successful operation
+          schema:
+            $ref: '#/definitions/User'
+        '400':
+          description: Invalid username supplied
+        '404':
+          description: User not found
+    put:
+      tags:
+        - user
+      summary: Updated user
+      description: This can only be done by the logged in user.
+      operationId: updateUser
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: username
+          in: path
+          description: name that need to be updated
+          required: true
+          type: string
+        - in: body
+          name: body
+          description: Updated user object
+          required: true
+          schema:
+            $ref: '#/definitions/User'
+      responses:
+        '400':
+          description: Invalid user supplied
+        '404':
+          description: User not found
+    delete:
+      tags:
+        - user
+      summary: Delete user
+      description: This can only be done by the logged in user.
+      operationId: deleteUser
+      produces:
+        - application/xml
+        - application/json
+      parameters:
+        - name: username
+          in: path
+          description: The name that needs to be deleted
+          required: true
+          type: string
+      responses:
+        '400':
+          description: Invalid username supplied
+        '404':
+          description: User not found
+securityDefinitions:
+  petstore_auth:
+    type: oauth2
+    authorizationUrl: http://petstore.swagger.io/oauth/dialog
+    flow: implicit
+    scopes:
+      write:pets: modify pets in your account
+      read:pets: read your pets
+  api_key:
+    type: apiKey
+    name: api_key
+    in: header
+definitions:
+  Order:
+    type: object
+    properties:
+      id:
+        type: integer
+        format: int64
+      petId:
+        type: integer
+        format: int64
+      quantity:
+        type: integer
+        format: int32
+      shipDate:
+        type: string
+        format: date-time
+      status:
+        type: string
+        description: Order Status
+        enum:
+          - placed
+          - approved
+          - delivered
+      complete:
+        type: boolean
+        default: false
+    xml:
+      name: Order
+  Category:
+    type: object
+    properties:
+      id:
+        type: integer
+        format: int64
+      name:
+        type: string
+    xml:
+      name: Category
+  User:
+    type: object
+    properties:
+      id:
+        type: integer
+        format: int64
+      username:
+        type: string
+      firstName:
+        type: string
+      lastName:
+        type: string
+      email:
+        type: string
+      password:
+        type: string
+      phone:
+        type: string
+      userStatus:
+        type: integer
+        format: int32
+        description: User Status
+    xml:
+      name: User
+  Tag:
+    type: object
+    properties:
+      id:
+        type: integer
+        format: int64
+      name:
+        type: string
+    xml:
+      name: Tag
+  Pet:
+    type: object
+    required:
+      - name
+      - photoUrls
+    properties:
+      id:
+        type: integer
+        format: int64
+      category:
+        $ref: '#/definitions/Category'
+      name:
+        type: string
+        example: doggie
+      photoUrls:
+        type: array
+        xml:
+          name: photoUrl
+          wrapped: true
+        items:
+          type: string
+      tags:
+        type: array
+        xml:
+          name: tag
+          wrapped: true
+        items:
+          $ref: '#/definitions/Tag'
+      status:
+        type: string
+        description: pet status in the store
+        enum:
+          - available
+          - pending
+          - sold
+    xml:
+      name: Pet
+  ApiResponse:
+    type: object
+    properties:
+      code:
+        type: integer
+        format: int32
+      type:
+        type: string
+      message:
+        type: string
+externalDocs:
+  description: Find out more about Swagger
+  url: http://swagger.io
diff --git a/example/lib/main.dart b/example/lib/main.dart
index ce2af5c5..ad3bc568 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,7 +1,7 @@
-import 'swagger_generated_code/example_swagger.swagger.dart';
+import 'package:example/swagger_generated_code/pet_service_yaml.swagger.dart';
 
 void main() async {
-  final petsApi = ExampleSwagger.create();
+  final petsApi = PetServiceYaml.create();
 
   final postResult = await petsApi.petPost(
     body: Pet(
diff --git a/example/lib/swagger_generated_code/client_index.dart b/example/lib/swagger_generated_code/client_index.dart
index 4f9ac425..2e45952a 100644
--- a/example/lib/swagger_generated_code/client_index.dart
+++ b/example/lib/swagger_generated_code/client_index.dart
@@ -1,2 +1,2 @@
-export 'example_swagger.swagger.dart' show ExampleSwagger;
-export 'pets_api.swagger.dart' show PetsApi;
+export 'pet_service_json.swagger.dart' show PetServiceJson;
+export 'pet_service_yaml.swagger.dart' show PetServiceYaml;
diff --git a/example/lib/swagger_generated_code/example_swagger.enums.swagger.dart b/example/lib/swagger_generated_code/pet_service_json.enums.swagger.dart
similarity index 100%
rename from example/lib/swagger_generated_code/example_swagger.enums.swagger.dart
rename to example/lib/swagger_generated_code/pet_service_json.enums.swagger.dart
diff --git a/example/lib/swagger_generated_code/example_swagger.swagger.chopper.dart b/example/lib/swagger_generated_code/pet_service_json.swagger.chopper.dart
similarity index 90%
rename from example/lib/swagger_generated_code/example_swagger.swagger.chopper.dart
rename to example/lib/swagger_generated_code/pet_service_json.swagger.chopper.dart
index e2501668..2ec71bf9 100644
--- a/example/lib/swagger_generated_code/example_swagger.swagger.chopper.dart
+++ b/example/lib/swagger_generated_code/pet_service_json.swagger.chopper.dart
@@ -1,20 +1,20 @@
 //Generated code
 
-part of 'example_swagger.swagger.dart';
+part of 'pet_service_json.swagger.dart';
 
 // **************************************************************************
 // ChopperGenerator
 // **************************************************************************
 
-// ignore_for_file: always_put_control_body_on_new_line, always_specify_types, prefer_const_declarations
-class _$ExampleSwagger extends ExampleSwagger {
-  _$ExampleSwagger([ChopperClient? client]) {
+// ignore_for_file: always_put_control_body_on_new_line, always_specify_types, prefer_const_declarations, unnecessary_brace_in_string_interps
+class _$PetServiceJson extends PetServiceJson {
+  _$PetServiceJson([ChopperClient? client]) {
     if (client == null) return;
     this.client = client;
   }
 
   @override
-  final definitionType = ExampleSwagger;
+  final definitionType = PetServiceJson;
 
   @override
   Future<Response<dynamic>> _petPost({required Pet? body}) {
@@ -50,7 +50,7 @@ class _$ExampleSwagger extends ExampleSwagger {
 
   @override
   Future<Response<Pet>> _petPetIdGet({required int? petId, String? apiKey}) {
-    final $url = '/pet/$petId';
+    final $url = '/pet/${petId}';
     final $headers = {
       if (apiKey != null) 'api_key': apiKey,
     };
@@ -62,7 +62,7 @@ class _$ExampleSwagger extends ExampleSwagger {
   @override
   Future<Response<dynamic>> _petPetIdPost(
       {required int? petId, String? name, String? status}) {
-    final $url = '/pet/$petId';
+    final $url = '/pet/${petId}';
     final $body = <String, dynamic>{'name': name, 'status': status};
     final $request = Request('POST', $url, client.baseUrl, body: $body);
     return client.send<dynamic, dynamic>($request);
@@ -71,7 +71,7 @@ class _$ExampleSwagger extends ExampleSwagger {
   @override
   Future<Response<dynamic>> _petPetIdDelete(
       {String? apiKey, required int? petId}) {
-    final $url = '/pet/$petId';
+    final $url = '/pet/${petId}';
     final $headers = {
       if (apiKey != null) 'api_key': apiKey,
     };
@@ -83,7 +83,7 @@ class _$ExampleSwagger extends ExampleSwagger {
   @override
   Future<Response<ApiResponse>> _petPetIdUploadImagePost(
       {required int? petId, String? additionalMetadata, List<String>? file}) {
-    final $url = '/pet/$petId/uploadImage';
+    final $url = '/pet/${petId}/uploadImage';
     final $body = <String, dynamic>{
       'additionalMetadata': additionalMetadata,
       'file': file
@@ -113,14 +113,14 @@ class _$ExampleSwagger extends ExampleSwagger {
 
   @override
   Future<Response<Order>> _storeOrderOrderIdGet({required int? orderId}) {
-    final $url = '/store/order/$orderId';
+    final $url = '/store/order/${orderId}';
     final $request = Request('GET', $url, client.baseUrl);
     return client.send<Order, Order>($request);
   }
 
   @override
   Future<Response<dynamic>> _storeOrderOrderIdDelete({required int? orderId}) {
-    final $url = '/store/order/$orderId';
+    final $url = '/store/order/${orderId}';
     final $request = Request('DELETE', $url, client.baseUrl);
     return client.send<dynamic, dynamic>($request);
   }
@@ -172,7 +172,7 @@ class _$ExampleSwagger extends ExampleSwagger {
 
   @override
   Future<Response<User>> _userUsernameGet({required String? username}) {
-    final $url = '/user/$username';
+    final $url = '/user/${username}';
     final $request = Request('GET', $url, client.baseUrl);
     return client.send<User, User>($request);
   }
@@ -180,7 +180,7 @@ class _$ExampleSwagger extends ExampleSwagger {
   @override
   Future<Response<dynamic>> _userUsernamePut(
       {required String? username, required User? body}) {
-    final $url = '/user/$username';
+    final $url = '/user/${username}';
     final $body = body;
     final $request = Request('PUT', $url, client.baseUrl, body: $body);
     return client.send<dynamic, dynamic>($request);
@@ -188,7 +188,7 @@ class _$ExampleSwagger extends ExampleSwagger {
 
   @override
   Future<Response<dynamic>> _userUsernameDelete({required String? username}) {
-    final $url = '/user/$username';
+    final $url = '/user/${username}';
     final $request = Request('DELETE', $url, client.baseUrl);
     return client.send<dynamic, dynamic>($request);
   }
diff --git a/example/lib/swagger_generated_code/example_swagger.swagger.dart b/example/lib/swagger_generated_code/pet_service_json.swagger.dart
similarity index 97%
rename from example/lib/swagger_generated_code/example_swagger.swagger.dart
rename to example/lib/swagger_generated_code/pet_service_json.swagger.dart
index a3ece609..8e3dd54e 100644
--- a/example/lib/swagger_generated_code/example_swagger.swagger.dart
+++ b/example/lib/swagger_generated_code/pet_service_json.swagger.dart
@@ -2,30 +2,32 @@ import 'package:json_annotation/json_annotation.dart';
 import 'package:collection/collection.dart';
 
 import 'package:chopper/chopper.dart';
+import 'dart:convert';
+
 import 'client_mapping.dart';
 import 'package:chopper/chopper.dart' as chopper;
-import 'example_swagger.enums.swagger.dart' as enums;
-export 'example_swagger.enums.swagger.dart';
+import 'pet_service_json.enums.swagger.dart' as enums;
+export 'pet_service_json.enums.swagger.dart';
 
-part 'example_swagger.swagger.chopper.dart';
-part 'example_swagger.swagger.g.dart';
+part 'pet_service_json.swagger.chopper.dart';
+part 'pet_service_json.swagger.g.dart';
 
 // **************************************************************************
 // SwaggerChopperGenerator
 // **************************************************************************
 
 @ChopperApi()
-abstract class ExampleSwagger extends ChopperService {
-  static ExampleSwagger create({ChopperClient? client, String? baseUrl}) {
+abstract class PetServiceJson extends ChopperService {
+  static PetServiceJson create({ChopperClient? client, String? baseUrl}) {
     if (client != null) {
-      return _$ExampleSwagger(client);
+      return _$PetServiceJson(client);
     }
 
     final newClient = ChopperClient(
-        services: [_$ExampleSwagger()],
+        services: [_$PetServiceJson()],
         converter: $JsonSerializableConverter(),
         baseUrl: baseUrl ?? 'http://petstore.swagger.io/v2');
-    return _$ExampleSwagger(newClient);
+    return _$PetServiceJson(newClient);
   }
 
   ///Add a new pet to the store
@@ -349,6 +351,9 @@ class Order {
   static const toJsonFactory = _$OrderToJson;
   Map<String, dynamic> toJson() => _$OrderToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -417,6 +422,9 @@ class Category {
   static const toJsonFactory = _$CategoryToJson;
   Map<String, dynamic> toJson() => _$CategoryToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -475,6 +483,9 @@ class User {
   static const toJsonFactory = _$UserToJson;
   Map<String, dynamic> toJson() => _$UserToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -554,6 +565,9 @@ class Tag {
   static const toJsonFactory = _$TagToJson;
   Map<String, dynamic> toJson() => _$TagToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -610,6 +624,9 @@ class Pet {
   static const toJsonFactory = _$PetToJson;
   Map<String, dynamic> toJson() => _$PetToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -680,6 +697,9 @@ class ApiResponse {
   static const toJsonFactory = _$ApiResponseToJson;
   Map<String, dynamic> toJson() => _$ApiResponseToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
diff --git a/example/lib/swagger_generated_code/pets_api.swagger.g.dart b/example/lib/swagger_generated_code/pet_service_json.swagger.g.dart
similarity index 58%
rename from example/lib/swagger_generated_code/pets_api.swagger.g.dart
rename to example/lib/swagger_generated_code/pet_service_json.swagger.g.dart
index 874d65e0..4edee5a8 100644
--- a/example/lib/swagger_generated_code/pets_api.swagger.g.dart
+++ b/example/lib/swagger_generated_code/pet_service_json.swagger.g.dart
@@ -1,23 +1,21 @@
 // GENERATED CODE - DO NOT MODIFY BY HAND
 
-part of 'pets_api.swagger.dart';
+part of 'pet_service_json.swagger.dart';
 
 // **************************************************************************
 // JsonSerializableGenerator
 // **************************************************************************
 
-Order _$OrderFromJson(Map<String, dynamic> json) {
-  return Order(
-    id: json['id'] as num?,
-    petId: json['petId'] as num?,
-    quantity: json['quantity'] as int?,
-    shipDate: json['shipDate'] == null
-        ? null
-        : DateTime.parse(json['shipDate'] as String),
-    status: orderStatusFromJson(json['status']),
-    complete: json['complete'] as bool? ?? false,
-  );
-}
+Order _$OrderFromJson(Map<String, dynamic> json) => Order(
+      id: json['id'] as num?,
+      petId: json['petId'] as num?,
+      quantity: json['quantity'] as int?,
+      shipDate: json['shipDate'] == null
+          ? null
+          : DateTime.parse(json['shipDate'] as String),
+      status: orderStatusFromJson(json['status']),
+      complete: json['complete'] as bool? ?? false,
+    );
 
 Map<String, dynamic> _$OrderToJson(Order instance) {
   final val = <String, dynamic>{};
@@ -37,12 +35,10 @@ Map<String, dynamic> _$OrderToJson(Order instance) {
   return val;
 }
 
-Category _$CategoryFromJson(Map<String, dynamic> json) {
-  return Category(
-    id: json['id'] as num?,
-    name: json['name'] as String? ?? '',
-  );
-}
+Category _$CategoryFromJson(Map<String, dynamic> json) => Category(
+      id: json['id'] as num?,
+      name: json['name'] as String? ?? '',
+    );
 
 Map<String, dynamic> _$CategoryToJson(Category instance) {
   final val = <String, dynamic>{};
@@ -58,18 +54,16 @@ Map<String, dynamic> _$CategoryToJson(Category instance) {
   return val;
 }
 
-User _$UserFromJson(Map<String, dynamic> json) {
-  return User(
-    id: json['id'] as num?,
-    username: json['username'] as String? ?? '',
-    firstName: json['firstName'] as String? ?? '',
-    lastName: json['lastName'] as String? ?? '',
-    email: json['email'] as String? ?? '',
-    password: json['password'] as String? ?? '',
-    phone: json['phone'] as String? ?? '',
-    userStatus: json['userStatus'] as int?,
-  );
-}
+User _$UserFromJson(Map<String, dynamic> json) => User(
+      id: json['id'] as num?,
+      username: json['username'] as String? ?? '',
+      firstName: json['firstName'] as String? ?? '',
+      lastName: json['lastName'] as String? ?? '',
+      email: json['email'] as String? ?? '',
+      password: json['password'] as String? ?? '',
+      phone: json['phone'] as String? ?? '',
+      userStatus: json['userStatus'] as int?,
+    );
 
 Map<String, dynamic> _$UserToJson(User instance) {
   final val = <String, dynamic>{};
@@ -91,12 +85,10 @@ Map<String, dynamic> _$UserToJson(User instance) {
   return val;
 }
 
-Tag _$TagFromJson(Map<String, dynamic> json) {
-  return Tag(
-    id: json['id'] as num?,
-    name: json['name'] as String? ?? '',
-  );
-}
+Tag _$TagFromJson(Map<String, dynamic> json) => Tag(
+      id: json['id'] as num?,
+      name: json['name'] as String? ?? '',
+    );
 
 Map<String, dynamic> _$TagToJson(Tag instance) {
   final val = <String, dynamic>{};
@@ -112,24 +104,22 @@ Map<String, dynamic> _$TagToJson(Tag instance) {
   return val;
 }
 
-Pet _$PetFromJson(Map<String, dynamic> json) {
-  return Pet(
-    id: json['id'] as num?,
-    category: json['category'] == null
-        ? null
-        : Category.fromJson(json['category'] as Map<String, dynamic>),
-    name: json['name'] as String? ?? '',
-    photoUrls: (json['photoUrls'] as List<dynamic>?)
-            ?.map((e) => e as String)
-            .toList() ??
-        [],
-    tags: (json['tags'] as List<dynamic>?)
-            ?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
-            .toList() ??
-        [],
-    status: petStatusFromJson(json['status']),
-  );
-}
+Pet _$PetFromJson(Map<String, dynamic> json) => Pet(
+      id: json['id'] as num?,
+      category: json['category'] == null
+          ? null
+          : Category.fromJson(json['category'] as Map<String, dynamic>),
+      name: json['name'] as String? ?? '',
+      photoUrls: (json['photoUrls'] as List<dynamic>?)
+              ?.map((e) => e as String)
+              .toList() ??
+          [],
+      tags: (json['tags'] as List<dynamic>?)
+              ?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
+              .toList() ??
+          [],
+      status: petStatusFromJson(json['status']),
+    );
 
 Map<String, dynamic> _$PetToJson(Pet instance) {
   final val = <String, dynamic>{};
@@ -149,13 +139,11 @@ Map<String, dynamic> _$PetToJson(Pet instance) {
   return val;
 }
 
-ApiResponse _$ApiResponseFromJson(Map<String, dynamic> json) {
-  return ApiResponse(
-    code: json['code'] as int?,
-    type: json['type'] as String? ?? '',
-    message: json['message'] as String? ?? '',
-  );
-}
+ApiResponse _$ApiResponseFromJson(Map<String, dynamic> json) => ApiResponse(
+      code: json['code'] as int?,
+      type: json['type'] as String? ?? '',
+      message: json['message'] as String? ?? '',
+    );
 
 Map<String, dynamic> _$ApiResponseToJson(ApiResponse instance) {
   final val = <String, dynamic>{};
diff --git a/example/lib/swagger_generated_code/pets_api.enums.swagger.dart b/example/lib/swagger_generated_code/pet_service_yaml.enums.swagger.dart
similarity index 100%
rename from example/lib/swagger_generated_code/pets_api.enums.swagger.dart
rename to example/lib/swagger_generated_code/pet_service_yaml.enums.swagger.dart
diff --git a/example/lib/swagger_generated_code/pets_api.swagger.chopper.dart b/example/lib/swagger_generated_code/pet_service_yaml.swagger.chopper.dart
similarity index 90%
rename from example/lib/swagger_generated_code/pets_api.swagger.chopper.dart
rename to example/lib/swagger_generated_code/pet_service_yaml.swagger.chopper.dart
index 510a3973..29bce74b 100644
--- a/example/lib/swagger_generated_code/pets_api.swagger.chopper.dart
+++ b/example/lib/swagger_generated_code/pet_service_yaml.swagger.chopper.dart
@@ -1,20 +1,20 @@
 //Generated code
 
-part of 'pets_api.swagger.dart';
+part of 'pet_service_yaml.swagger.dart';
 
 // **************************************************************************
 // ChopperGenerator
 // **************************************************************************
 
-// ignore_for_file: always_put_control_body_on_new_line, always_specify_types, prefer_const_declarations
-class _$PetsApi extends PetsApi {
-  _$PetsApi([ChopperClient? client]) {
+// ignore_for_file: always_put_control_body_on_new_line, always_specify_types, prefer_const_declarations, unnecessary_brace_in_string_interps
+class _$PetServiceYaml extends PetServiceYaml {
+  _$PetServiceYaml([ChopperClient? client]) {
     if (client == null) return;
     this.client = client;
   }
 
   @override
-  final definitionType = PetsApi;
+  final definitionType = PetServiceYaml;
 
   @override
   Future<Response<dynamic>> _petPost({required Pet? body}) {
@@ -50,7 +50,7 @@ class _$PetsApi extends PetsApi {
 
   @override
   Future<Response<Pet>> _petPetIdGet({required int? petId, String? apiKey}) {
-    final $url = '/pet/$petId';
+    final $url = '/pet/${petId}';
     final $headers = {
       if (apiKey != null) 'api_key': apiKey,
     };
@@ -62,7 +62,7 @@ class _$PetsApi extends PetsApi {
   @override
   Future<Response<dynamic>> _petPetIdPost(
       {required int? petId, String? name, String? status}) {
-    final $url = '/pet/$petId';
+    final $url = '/pet/${petId}';
     final $body = <String, dynamic>{'name': name, 'status': status};
     final $request = Request('POST', $url, client.baseUrl, body: $body);
     return client.send<dynamic, dynamic>($request);
@@ -71,7 +71,7 @@ class _$PetsApi extends PetsApi {
   @override
   Future<Response<dynamic>> _petPetIdDelete(
       {String? apiKey, required int? petId}) {
-    final $url = '/pet/$petId';
+    final $url = '/pet/${petId}';
     final $headers = {
       if (apiKey != null) 'api_key': apiKey,
     };
@@ -83,7 +83,7 @@ class _$PetsApi extends PetsApi {
   @override
   Future<Response<ApiResponse>> _petPetIdUploadImagePost(
       {required int? petId, String? additionalMetadata, List<String>? file}) {
-    final $url = '/pet/$petId/uploadImage';
+    final $url = '/pet/${petId}/uploadImage';
     final $body = <String, dynamic>{
       'additionalMetadata': additionalMetadata,
       'file': file
@@ -113,14 +113,14 @@ class _$PetsApi extends PetsApi {
 
   @override
   Future<Response<Order>> _storeOrderOrderIdGet({required int? orderId}) {
-    final $url = '/store/order/$orderId';
+    final $url = '/store/order/${orderId}';
     final $request = Request('GET', $url, client.baseUrl);
     return client.send<Order, Order>($request);
   }
 
   @override
   Future<Response<dynamic>> _storeOrderOrderIdDelete({required int? orderId}) {
-    final $url = '/store/order/$orderId';
+    final $url = '/store/order/${orderId}';
     final $request = Request('DELETE', $url, client.baseUrl);
     return client.send<dynamic, dynamic>($request);
   }
@@ -172,7 +172,7 @@ class _$PetsApi extends PetsApi {
 
   @override
   Future<Response<User>> _userUsernameGet({required String? username}) {
-    final $url = '/user/$username';
+    final $url = '/user/${username}';
     final $request = Request('GET', $url, client.baseUrl);
     return client.send<User, User>($request);
   }
@@ -180,7 +180,7 @@ class _$PetsApi extends PetsApi {
   @override
   Future<Response<dynamic>> _userUsernamePut(
       {required String? username, required User? body}) {
-    final $url = '/user/$username';
+    final $url = '/user/${username}';
     final $body = body;
     final $request = Request('PUT', $url, client.baseUrl, body: $body);
     return client.send<dynamic, dynamic>($request);
@@ -188,7 +188,7 @@ class _$PetsApi extends PetsApi {
 
   @override
   Future<Response<dynamic>> _userUsernameDelete({required String? username}) {
-    final $url = '/user/$username';
+    final $url = '/user/${username}';
     final $request = Request('DELETE', $url, client.baseUrl);
     return client.send<dynamic, dynamic>($request);
   }
diff --git a/example/lib/swagger_generated_code/pets_api.swagger.dart b/example/lib/swagger_generated_code/pet_service_yaml.swagger.dart
similarity index 97%
rename from example/lib/swagger_generated_code/pets_api.swagger.dart
rename to example/lib/swagger_generated_code/pet_service_yaml.swagger.dart
index 5d558f31..33c4cbcf 100644
--- a/example/lib/swagger_generated_code/pets_api.swagger.dart
+++ b/example/lib/swagger_generated_code/pet_service_yaml.swagger.dart
@@ -2,30 +2,32 @@ import 'package:json_annotation/json_annotation.dart';
 import 'package:collection/collection.dart';
 
 import 'package:chopper/chopper.dart';
+import 'dart:convert';
+
 import 'client_mapping.dart';
 import 'package:chopper/chopper.dart' as chopper;
-import 'pets_api.enums.swagger.dart' as enums;
-export 'pets_api.enums.swagger.dart';
+import 'pet_service_yaml.enums.swagger.dart' as enums;
+export 'pet_service_yaml.enums.swagger.dart';
 
-part 'pets_api.swagger.chopper.dart';
-part 'pets_api.swagger.g.dart';
+part 'pet_service_yaml.swagger.chopper.dart';
+part 'pet_service_yaml.swagger.g.dart';
 
 // **************************************************************************
 // SwaggerChopperGenerator
 // **************************************************************************
 
 @ChopperApi()
-abstract class PetsApi extends ChopperService {
-  static PetsApi create({ChopperClient? client, String? baseUrl}) {
+abstract class PetServiceYaml extends ChopperService {
+  static PetServiceYaml create({ChopperClient? client, String? baseUrl}) {
     if (client != null) {
-      return _$PetsApi(client);
+      return _$PetServiceYaml(client);
     }
 
     final newClient = ChopperClient(
-        services: [_$PetsApi()],
+        services: [_$PetServiceYaml()],
         converter: $JsonSerializableConverter(),
         baseUrl: baseUrl ?? 'http://petstore.swagger.io/v2');
-    return _$PetsApi(newClient);
+    return _$PetServiceYaml(newClient);
   }
 
   ///Add a new pet to the store
@@ -349,6 +351,9 @@ class Order {
   static const toJsonFactory = _$OrderToJson;
   Map<String, dynamic> toJson() => _$OrderToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -417,6 +422,9 @@ class Category {
   static const toJsonFactory = _$CategoryToJson;
   Map<String, dynamic> toJson() => _$CategoryToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -475,6 +483,9 @@ class User {
   static const toJsonFactory = _$UserToJson;
   Map<String, dynamic> toJson() => _$UserToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -554,6 +565,9 @@ class Tag {
   static const toJsonFactory = _$TagToJson;
   Map<String, dynamic> toJson() => _$TagToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -610,6 +624,9 @@ class Pet {
   static const toJsonFactory = _$PetToJson;
   Map<String, dynamic> toJson() => _$PetToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
@@ -680,6 +697,9 @@ class ApiResponse {
   static const toJsonFactory = _$ApiResponseToJson;
   Map<String, dynamic> toJson() => _$ApiResponseToJson(this);
 
+  @override
+  String toString() => jsonEncode(this);
+
   @override
   bool operator ==(dynamic other) {
     return identical(this, other) ||
diff --git a/example/lib/swagger_generated_code/example_swagger.swagger.g.dart b/example/lib/swagger_generated_code/pet_service_yaml.swagger.g.dart
similarity index 58%
rename from example/lib/swagger_generated_code/example_swagger.swagger.g.dart
rename to example/lib/swagger_generated_code/pet_service_yaml.swagger.g.dart
index c5d1059f..27d11945 100644
--- a/example/lib/swagger_generated_code/example_swagger.swagger.g.dart
+++ b/example/lib/swagger_generated_code/pet_service_yaml.swagger.g.dart
@@ -1,23 +1,21 @@
 // GENERATED CODE - DO NOT MODIFY BY HAND
 
-part of 'example_swagger.swagger.dart';
+part of 'pet_service_yaml.swagger.dart';
 
 // **************************************************************************
 // JsonSerializableGenerator
 // **************************************************************************
 
-Order _$OrderFromJson(Map<String, dynamic> json) {
-  return Order(
-    id: json['id'] as num?,
-    petId: json['petId'] as num?,
-    quantity: json['quantity'] as int?,
-    shipDate: json['shipDate'] == null
-        ? null
-        : DateTime.parse(json['shipDate'] as String),
-    status: orderStatusFromJson(json['status']),
-    complete: json['complete'] as bool? ?? false,
-  );
-}
+Order _$OrderFromJson(Map<String, dynamic> json) => Order(
+      id: json['id'] as num?,
+      petId: json['petId'] as num?,
+      quantity: json['quantity'] as int?,
+      shipDate: json['shipDate'] == null
+          ? null
+          : DateTime.parse(json['shipDate'] as String),
+      status: orderStatusFromJson(json['status']),
+      complete: json['complete'] as bool? ?? false,
+    );
 
 Map<String, dynamic> _$OrderToJson(Order instance) {
   final val = <String, dynamic>{};
@@ -37,12 +35,10 @@ Map<String, dynamic> _$OrderToJson(Order instance) {
   return val;
 }
 
-Category _$CategoryFromJson(Map<String, dynamic> json) {
-  return Category(
-    id: json['id'] as num?,
-    name: json['name'] as String? ?? '',
-  );
-}
+Category _$CategoryFromJson(Map<String, dynamic> json) => Category(
+      id: json['id'] as num?,
+      name: json['name'] as String? ?? '',
+    );
 
 Map<String, dynamic> _$CategoryToJson(Category instance) {
   final val = <String, dynamic>{};
@@ -58,18 +54,16 @@ Map<String, dynamic> _$CategoryToJson(Category instance) {
   return val;
 }
 
-User _$UserFromJson(Map<String, dynamic> json) {
-  return User(
-    id: json['id'] as num?,
-    username: json['username'] as String? ?? '',
-    firstName: json['firstName'] as String? ?? '',
-    lastName: json['lastName'] as String? ?? '',
-    email: json['email'] as String? ?? '',
-    password: json['password'] as String? ?? '',
-    phone: json['phone'] as String? ?? '',
-    userStatus: json['userStatus'] as int?,
-  );
-}
+User _$UserFromJson(Map<String, dynamic> json) => User(
+      id: json['id'] as num?,
+      username: json['username'] as String? ?? '',
+      firstName: json['firstName'] as String? ?? '',
+      lastName: json['lastName'] as String? ?? '',
+      email: json['email'] as String? ?? '',
+      password: json['password'] as String? ?? '',
+      phone: json['phone'] as String? ?? '',
+      userStatus: json['userStatus'] as int?,
+    );
 
 Map<String, dynamic> _$UserToJson(User instance) {
   final val = <String, dynamic>{};
@@ -91,12 +85,10 @@ Map<String, dynamic> _$UserToJson(User instance) {
   return val;
 }
 
-Tag _$TagFromJson(Map<String, dynamic> json) {
-  return Tag(
-    id: json['id'] as num?,
-    name: json['name'] as String? ?? '',
-  );
-}
+Tag _$TagFromJson(Map<String, dynamic> json) => Tag(
+      id: json['id'] as num?,
+      name: json['name'] as String? ?? '',
+    );
 
 Map<String, dynamic> _$TagToJson(Tag instance) {
   final val = <String, dynamic>{};
@@ -112,24 +104,22 @@ Map<String, dynamic> _$TagToJson(Tag instance) {
   return val;
 }
 
-Pet _$PetFromJson(Map<String, dynamic> json) {
-  return Pet(
-    id: json['id'] as num?,
-    category: json['category'] == null
-        ? null
-        : Category.fromJson(json['category'] as Map<String, dynamic>),
-    name: json['name'] as String? ?? '',
-    photoUrls: (json['photoUrls'] as List<dynamic>?)
-            ?.map((e) => e as String)
-            .toList() ??
-        [],
-    tags: (json['tags'] as List<dynamic>?)
-            ?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
-            .toList() ??
-        [],
-    status: petStatusFromJson(json['status']),
-  );
-}
+Pet _$PetFromJson(Map<String, dynamic> json) => Pet(
+      id: json['id'] as num?,
+      category: json['category'] == null
+          ? null
+          : Category.fromJson(json['category'] as Map<String, dynamic>),
+      name: json['name'] as String? ?? '',
+      photoUrls: (json['photoUrls'] as List<dynamic>?)
+              ?.map((e) => e as String)
+              .toList() ??
+          [],
+      tags: (json['tags'] as List<dynamic>?)
+              ?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
+              .toList() ??
+          [],
+      status: petStatusFromJson(json['status']),
+    );
 
 Map<String, dynamic> _$PetToJson(Pet instance) {
   final val = <String, dynamic>{};
@@ -149,13 +139,11 @@ Map<String, dynamic> _$PetToJson(Pet instance) {
   return val;
 }
 
-ApiResponse _$ApiResponseFromJson(Map<String, dynamic> json) {
-  return ApiResponse(
-    code: json['code'] as int?,
-    type: json['type'] as String? ?? '',
-    message: json['message'] as String? ?? '',
-  );
-}
+ApiResponse _$ApiResponseFromJson(Map<String, dynamic> json) => ApiResponse(
+      code: json['code'] as int?,
+      type: json['type'] as String? ?? '',
+      message: json['message'] as String? ?? '',
+    );
 
 Map<String, dynamic> _$ApiResponseToJson(ApiResponse instance) {
   final val = <String, dynamic>{};
diff --git a/lib/src/code_generators/swagger_additions_generator.dart b/lib/src/code_generators/swagger_additions_generator.dart
index fc3ba7ae..1b4e2da9 100644
--- a/lib/src/code_generators/swagger_additions_generator.dart
+++ b/lib/src/code_generators/swagger_additions_generator.dart
@@ -12,7 +12,8 @@ class SwaggerAdditionsGenerator {
           .split('/')
           .last
           .replaceAll('-', '_')
-          .replaceAll('.json', '.swagger');
+          .replaceAll('.json', '.swagger')
+          .replaceAll('.yaml', '.swagger');
       final className = getClassNameFromFileName(key.split('/').last);
 
       return 'export \'$fileName.dart\' show $className;';
diff --git a/lib/src/code_generators/swagger_enums_generator.dart b/lib/src/code_generators/swagger_enums_generator.dart
index 48b2dcc3..69194d36 100644
--- a/lib/src/code_generators/swagger_enums_generator.dart
+++ b/lib/src/code_generators/swagger_enums_generator.dart
@@ -1,4 +1,3 @@
-import 'dart:convert';
 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';
@@ -14,16 +13,15 @@ abstract class SwaggerEnumsGenerator {
   static const String defaultEnumFieldName = 'value_';
   static const String defaultEnumValueName = 'swaggerGeneratedUnknown';
 
-  String generate(String dartCode, String fileName);
+  String generate(Map<String, dynamic> map, String fileName);
 
   String generateFromMap(
-      String dartCode,
+      Map<String, dynamic> map,
       String fileName,
       Map<String, dynamic> definitions,
       Map<String, dynamic> responses,
       Map<String, dynamic> requestBodies) {
-    final enumsFromRequests =
-        generateEnumsContentFromRequests(dartCode, fileName);
+    final enumsFromRequests = generateEnumsContentFromRequests(map, fileName);
 
     final enumsFromResponses = generateEnumsFromResponses(responses);
 
@@ -142,10 +140,10 @@ $enumsFromRequestBodies
     return neededParameter;
   }
 
-  String generateEnumsContentFromRequests(String swagger, String fileName) {
+  String generateEnumsContentFromRequests(
+      Map<String, dynamic> map, String fileName) {
     final enumNames = <String>[];
     final result = StringBuffer();
-    final map = jsonDecode(swagger) as Map<String, dynamic>;
     final swaggerRoot = SwaggerRoot.fromJson(map);
 
     final definedParameters = <String, SwaggerRequestParameter>{};
@@ -321,9 +319,8 @@ $enumMap
     return result.lower;
   }
 
-  static List<String> getEnumNamesFromRequests(String swagger) {
+  static List<String> getEnumNamesFromRequests(Map<String, dynamic> map) {
     final enumNames = <String>[];
-    final map = jsonDecode(swagger) as Map<String, dynamic>;
     final swaggerRoot = SwaggerRoot.fromJson(map);
 
     //Link defined parameters with requests
diff --git a/lib/src/code_generators/swagger_models_generator.dart b/lib/src/code_generators/swagger_models_generator.dart
index 96b675da..004705f2 100644
--- a/lib/src/code_generators/swagger_models_generator.dart
+++ b/lib/src/code_generators/swagger_models_generator.dart
@@ -13,17 +13,18 @@ import 'package:swagger_dart_code_generator/src/exception_words.dart';
 import 'constants.dart';
 
 abstract class SwaggerModelsGenerator {
-  String generate(String dartCode, String fileName, GeneratorOptions options);
+  String generate(
+      Map<String, dynamic> map, String fileName, GeneratorOptions options);
   String generateResponses(
-      String dartCode, String fileName, GeneratorOptions options);
+      Map<String, dynamic> map, String fileName, GeneratorOptions options);
 
   String generateRequestBodies(
-      String dartCode, String fileName, GeneratorOptions options);
+      Map<String, dynamic> map, String fileName, GeneratorOptions options);
   String getExtendsString(Map<String, dynamic> map);
-  List<String> getAllListEnumNames(String swaggerFile);
+  List<String> getAllListEnumNames(Map<String, dynamic> map);
 
   String generateModelClassContent(
-      String swaggerFile,
+      Map<String, dynamic> rootMap,
       String className,
       Map<String, dynamic> map,
       Map<String, dynamic> schemas,
@@ -51,7 +52,7 @@ abstract class SwaggerModelsGenerator {
     }
 
     return generateModelClassString(
-      swaggerFile,
+      rootMap,
       className,
       map,
       schemas,
@@ -100,12 +101,12 @@ abstract class SwaggerModelsGenerator {
   }
 
   static Map<String, dynamic> getClassesFromResponses(
-      String dartCode, GeneratorOptions options) {
-    final swagger = jsonDecode(dartCode);
-
+    Map<String, dynamic> map,
+    GeneratorOptions options,
+  ) {
     final results = <String, dynamic>{};
 
-    final paths = swagger['paths'] as Map<String, dynamic>?;
+    final paths = map['paths'] as Map<String, dynamic>?;
     if (paths == null) {
       return results;
     }
@@ -172,20 +173,20 @@ abstract class SwaggerModelsGenerator {
   }
 
   String generateBase(
-      String dartCode,
+      Map<String, dynamic> map,
       String fileName,
       GeneratorOptions options,
       Map<String, dynamic> classes,
       bool generateFromJsonToJsonForRequests) {
-    final allEnumsNames = getAllEnumNames(dartCode);
-    final allEnumListNames = getAllListEnumNames(dartCode);
+    final allEnumsNames = getAllEnumNames(map);
+    final allEnumListNames = getAllListEnumNames(map);
 
     final generatedEnumFromJsonToJson = generateFromJsonToJsonForRequests
         ? genetateEnumFromJsonToJsonMethods(
             allEnumsNames, options.enumsCaseSensitive)
         : '';
 
-    final classesFromResponses = getClassesFromResponses(dartCode, options);
+    final classesFromResponses = getClassesFromResponses(map, options);
     classes.addAll(classesFromResponses);
 
     final classesFromInnerClasses =
@@ -203,7 +204,7 @@ abstract class SwaggerModelsGenerator {
       }
 
       return generateModelClassContent(
-        dartCode,
+        map,
         className.pascalCase,
         classes[className] as Map<String, dynamic>,
         classes,
@@ -217,7 +218,7 @@ abstract class SwaggerModelsGenerator {
 
     var results = '$generatedClasses\n$generatedEnumFromJsonToJson';
 
-    final listEnums = getAllListEnumNames(dartCode);
+    final listEnums = getAllListEnumNames(map);
 
     for (var listEnum in listEnums) {
       results = results.replaceAll(' $listEnum ', ' List<$listEnum> ');
@@ -881,7 +882,7 @@ abstract class SwaggerModelsGenerator {
   }
 
   String generatePropertiesContent(
-      String swagger,
+      Map<String, dynamic> rootMap,
       Map<String, dynamic> propertiesMap,
       Map<String, dynamic> schemas,
       String className,
@@ -907,7 +908,7 @@ abstract class SwaggerModelsGenerator {
 
       final propertyKey = propertyName;
 
-      final basicTypesMap = generateBasicTypesMapFromSchemas(swagger);
+      final basicTypesMap = generateBasicTypesMapFromSchemas(rootMap);
 
       propertyName = propertyName.asParameterName();
 
@@ -966,23 +967,26 @@ abstract class SwaggerModelsGenerator {
   }
 
   static Map<String, String> generateBasicTypesMapFromSchemas(
-      String swaggerFile) {
+      Map<String, dynamic> rootMap) {
     final result = <String, String>{};
 
-    final swagger = jsonDecode(swaggerFile);
+    final map = Map.from(rootMap);
 
-    final components = swagger['components'] as Map<String, dynamic>? ?? {};
+    final components = map['components'] as Map<String, dynamic>? ?? {};
 
-    final definitions = swagger['definitions'] as Map<String, dynamic>? ?? {};
+    final definitions = rootMap['definitions'] as Map<String, dynamic>? ?? {};
 
     final schemas = components['schemas'] as Map<String, dynamic>? ?? {};
 
     final responses = components['responses'] as Map<String, dynamic>? ?? {};
 
-    schemas.addAll(definitions);
-    schemas.addAll(responses);
+    final allClasses = {
+      ...definitions,
+      ...responses,
+      ...schemas,
+    };
 
-    schemas.forEach((key, value) {
+    allClasses.forEach((key, value) {
       if (kBasicTypes.contains(value['type'].toString().toLowerCase()) &&
           value['enum'] == null) {
         result.addAll({
@@ -1123,7 +1127,7 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
   }
 
   String generateModelClassString(
-      String swaggerFile,
+      Map<String, dynamic> rootMap,
       String className,
       Map<String, dynamic> map,
       Map<String, dynamic> schemas,
@@ -1144,7 +1148,7 @@ List<enums.$neededName> ${neededName.camelCase}ListFromJson(
     );
 
     final generatedProperties = generatePropertiesContent(
-      swaggerFile,
+      rootMap,
       properties,
       schemas,
       className,
@@ -1309,14 +1313,12 @@ $allHashComponents;
     return currentProperties;
   }
 
-  List<String> getAllEnumNames(String swaggerFile) {
-    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(swaggerFile);
+  List<String> getAllEnumNames(Map<String, dynamic> map) {
+    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
 
-    final swagger = jsonDecode(swaggerFile) as Map<String, dynamic>;
-
-    final components = swagger['components'] as Map<String, dynamic>?;
+    final components = map['components'] as Map<String, dynamic>?;
 
-    final definitions = swagger['definitions'] as Map<String, dynamic>? ?? {};
+    final definitions = map['definitions'] as Map<String, dynamic>? ?? {};
 
     final schemas = components == null
         ? <String, dynamic>{}
@@ -1332,7 +1334,7 @@ $allHashComponents;
         ? <String, dynamic>{}
         : components['requestBodies'] as Map<String, dynamic>? ?? {};
 
-    final moreRequestBodies = getRequestBodiesFromRequests(swagger);
+    final moreRequestBodies = getRequestBodiesFromRequests(map);
 
     requestBodies.addAll(moreRequestBodies);
 
diff --git a/lib/src/code_generators/swagger_requests_generator.dart b/lib/src/code_generators/swagger_requests_generator.dart
index 74aea1b6..dc275f27 100644
--- a/lib/src/code_generators/swagger_requests_generator.dart
+++ b/lib/src/code_generators/swagger_requests_generator.dart
@@ -1,5 +1,3 @@
-import 'dart:convert';
-
 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/models/generator_options.dart';
@@ -19,12 +17,11 @@ import 'constants.dart';
 
 class SwaggerRequestsGenerator {
   String generate({
-    required String code,
+    required Map<String, dynamic> map,
     required String className,
     required String fileName,
     required GeneratorOptions options,
   }) {
-    final map = jsonDecode(code) as Map<String, dynamic>;
     final swaggerRoot = SwaggerRoot.fromJson(map);
 
     final service = _generateService(
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 e882ceef..510d8ceb 100644
--- a/lib/src/code_generators/v2/swagger_enums_generator_v2.dart
+++ b/lib/src/code_generators/v2/swagger_enums_generator_v2.dart
@@ -1,13 +1,10 @@
-import 'dart:convert';
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_enums_generator.dart';
 
 class SwaggerEnumsGeneratorV2 extends SwaggerEnumsGenerator {
   @override
-  String generate(String dartCode, String fileName) {
-    final dynamic map = jsonDecode(dartCode);
-
+  String generate(Map<String, dynamic> map, String fileName) {
     final definitions = map['definitions'] as Map<String, dynamic>? ?? {};
 
-    return generateFromMap(dartCode, fileName, definitions, {}, {});
+    return generateFromMap(map, fileName, definitions, {}, {});
   }
 }
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 22b5f4c9..8e3475fc 100644
--- a/lib/src/code_generators/v2/swagger_models_generator_v2.dart
+++ b/lib/src/code_generators/v2/swagger_models_generator_v2.dart
@@ -1,4 +1,3 @@
-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/swagger_models_generator.dart';
 import 'package:swagger_dart_code_generator/src/extensions/string_extension.dart';
@@ -6,31 +5,29 @@ import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 
 class SwaggerModelsGeneratorV2 extends SwaggerModelsGenerator {
   @override
-  String generate(String dartCode, String fileName, GeneratorOptions options) {
-    final dynamic map = jsonDecode(dartCode);
+  String generate(
+      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
     final definitions = map['definitions'] as Map<String, dynamic>?;
-    return generateBase(dartCode, fileName, options, definitions ?? {}, true);
+    return generateBase(map, fileName, options, definitions ?? {}, true);
   }
 
   @override
   String generateResponses(
-      String dartCode, String fileName, GeneratorOptions options) {
+      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
     return '';
   }
 
   @override
   String generateRequestBodies(
-      String dartCode, String fileName, GeneratorOptions options) {
+      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
     return '';
   }
 
   @override
-  List<String> getAllListEnumNames(String swaggerFile) {
-    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(swaggerFile);
+  List<String> getAllListEnumNames(Map<String, dynamic> map) {
+    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
 
-    final swagger = jsonDecode(swaggerFile);
-
-    final definitions = swagger['definitions'] as Map<String, dynamic>?;
+    final definitions = map['definitions'] as Map<String, dynamic>?;
 
     if (definitions != null) {
       definitions.forEach((className, map) {
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 849a247b..71b32c7e 100644
--- a/lib/src/code_generators/v3/swagger_enums_generator_v3.dart
+++ b/lib/src/code_generators/v3/swagger_enums_generator_v3.dart
@@ -1,12 +1,9 @@
-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/swagger_models_generator.dart';
 
 class SwaggerEnumsGeneratorV3 extends SwaggerEnumsGenerator {
   @override
-  String generate(String dartCode, String fileName) {
-    final map = jsonDecode(dartCode) as Map<String, dynamic>;
-
+  String generate(Map<String, dynamic> map, String fileName) {
     final components = map['components'] as Map<String, dynamic>?;
     final schemas = components == null
         ? null
@@ -24,7 +21,7 @@ class SwaggerEnumsGeneratorV3 extends SwaggerEnumsGenerator {
         .addAll(SwaggerModelsGenerator.getRequestBodiesFromRequests(map));
 
     return generateFromMap(
-      dartCode,
+      map,
       fileName,
       schemas ?? {},
       responses ?? {},
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 147752f7..94981254 100644
--- a/lib/src/code_generators/v3/swagger_models_generator_v3.dart
+++ b/lib/src/code_generators/v3/swagger_models_generator_v3.dart
@@ -1,4 +1,3 @@
-import 'dart:convert';
 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';
@@ -9,22 +8,19 @@ import 'package:collection/collection.dart';
 
 class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
   @override
-  String generate(String dartCode, String fileName, GeneratorOptions options) {
-    final dynamic map = jsonDecode(dartCode);
-
+  String generate(
+      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
     final components = map['components'] as Map<String, dynamic>?;
     final schemas = components == null
         ? null
         : components['schemas'] as Map<String, dynamic>?;
 
-    return generateBase(dartCode, fileName, options, schemas ?? {}, true);
+    return generateBase(map, fileName, options, schemas ?? {}, true);
   }
 
   @override
   String generateResponses(
-      String dartCode, String fileName, GeneratorOptions options) {
-    final dynamic map = jsonDecode(dartCode);
-
+      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
     final components = map['components'] as Map<String, dynamic>?;
     final responses = components == null
         ? null
@@ -62,13 +58,11 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
       }
     }
 
-    return generateBase(dartCode, fileName, options, result, false);
+    return generateBase(map, fileName, options, result, false);
   }
 
-  Map<String, dynamic> _getRequestBodiesFromRequests(String dartCode) {
-    final root = jsonDecode(dartCode) as Map<String, dynamic>;
-
-    final paths = root['paths'] as Map<String, dynamic>?;
+  Map<String, dynamic> _getRequestBodiesFromRequests(Map<String, dynamic> map) {
+    final paths = map['paths'] as Map<String, dynamic>?;
 
     if (paths == null) {
       return {};
@@ -115,16 +109,14 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
 
   @override
   String generateRequestBodies(
-      String dartCode, String fileName, GeneratorOptions options) {
-    final dynamic map = jsonDecode(dartCode);
-
+      Map<String, dynamic> map, String fileName, GeneratorOptions options) {
     final components = map['components'] as Map<String, dynamic>?;
     final requestBodies = components == null
         ? <String, dynamic>{}
         : components['requestBodies'] as Map<String, dynamic>? ??
             <String, dynamic>{};
 
-    requestBodies.addAll(_getRequestBodiesFromRequests(dartCode));
+    requestBodies.addAll(_getRequestBodiesFromRequests(map));
 
     if (requestBodies.isEmpty) {
       return '';
@@ -158,16 +150,14 @@ class SwaggerModelsGeneratorV3 extends SwaggerModelsGenerator {
       }
     }
 
-    return generateBase(dartCode, fileName, options, result, false);
+    return generateBase(map, fileName, options, result, false);
   }
 
   @override
-  List<String> getAllListEnumNames(String swaggerFile) {
-    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(swaggerFile);
-
-    final swagger = jsonDecode(swaggerFile);
+  List<String> getAllListEnumNames(Map<String, dynamic> map) {
+    final results = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
 
-    final components = swagger['components'] as Map<String, dynamic>?;
+    final components = map['components'] as Map<String, dynamic>?;
 
     final schemas = components == null
         ? null
diff --git a/lib/src/extensions/yaml_extensions.dart b/lib/src/extensions/yaml_extensions.dart
new file mode 100644
index 00000000..1f53289c
--- /dev/null
+++ b/lib/src/extensions/yaml_extensions.dart
@@ -0,0 +1,25 @@
+import 'package:yaml/yaml.dart';
+
+extension YamlMapConverter on YamlMap {
+  dynamic _convertNode(dynamic v) {
+    if (v is YamlMap) {
+      return (v).toMap();
+    } else if (v is YamlList) {
+      var list = <dynamic>[];
+      for (var e in v) {
+        list.add(_convertNode(e));
+      }
+      return list;
+    } else {
+      return v;
+    }
+  }
+
+  Map<String, dynamic> toMap() {
+    var map = <String, dynamic>{};
+    nodes.forEach((k, v) {
+      map[(k as YamlScalar).value.toString()] = _convertNode(v.value);
+    });
+    return map;
+  }
+}
diff --git a/lib/src/swagger_code_generator.dart b/lib/src/swagger_code_generator.dart
index b265c66a..a894c318 100644
--- a/lib/src/swagger_code_generator.dart
+++ b/lib/src/swagger_code_generator.dart
@@ -1,5 +1,3 @@
-import 'dart:convert';
-
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_additions_generator.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';
@@ -23,9 +21,7 @@ class SwaggerCodeGenerator {
     3: SwaggerModelsGeneratorV3()
   };
 
-  int _getApiVersion(String dartCode) {
-    final dynamic map = jsonDecode(dartCode);
-
+  int _getApiVersion(Map map) {
     final openApi = map['openapi'] as String?;
     return openApi != null ? 3 : 2;
   }
@@ -47,27 +43,32 @@ class SwaggerCodeGenerator {
           hasModels, buildOnlyModels, hasEnums, separateModels);
 
   String generateResponses(
-          String dartCode, String fileName, GeneratorOptions options) =>
-      _getSwaggerModelsGenerator(dartCode)
-          .generateResponses(dartCode, fileName, options);
+    Map<String, dynamic> map,
+    String fileName,
+    GeneratorOptions options,
+  ) =>
+      _getSwaggerModelsGenerator(map).generateResponses(map, fileName, options);
 
   String generateRequestBodies(
-          String dartCode, String fileName, GeneratorOptions options) =>
-      _getSwaggerModelsGenerator(dartCode)
-          .generateRequestBodies(dartCode, fileName, options);
+    Map<String, dynamic> map,
+    String fileName,
+    GeneratorOptions options,
+  ) =>
+      _getSwaggerModelsGenerator(map)
+          .generateRequestBodies(map, fileName, options);
 
-  String generateEnums(String dartCode, String fileName) =>
-      _getSwaggerEnumsGenerator(dartCode).generate(dartCode, fileName);
+  String generateEnums(Map<String, dynamic> map, String fileName) =>
+      _getSwaggerEnumsGenerator(map).generate(map, fileName);
 
-  String generateModels(
-          String dartCode, String fileName, GeneratorOptions options) =>
+  String generateModels(Map<String, dynamic> dartCode, String fileName,
+          GeneratorOptions options) =>
       _getSwaggerModelsGenerator(dartCode)
           .generate(dartCode, fileName, options);
 
-  String generateRequests(String dartCode, String className, String fileName,
-          GeneratorOptions options) =>
-      _getSwaggerRequestsGenerator(dartCode).generate(
-        code: dartCode,
+  String generateRequests(Map<String, dynamic> map, String className,
+          String fileName, GeneratorOptions options) =>
+      _getSwaggerRequestsGenerator(map).generate(
+        map: map,
         className: className,
         fileName: fileName,
         options: options,
@@ -84,12 +85,12 @@ class SwaggerCodeGenerator {
   SwaggerAdditionsGenerator _getSwaggerAdditionsGenerator() =>
       SwaggerAdditionsGenerator();
 
-  SwaggerEnumsGenerator _getSwaggerEnumsGenerator(String dartCode) =>
-      _enumsMap[_getApiVersion(dartCode)]!;
+  SwaggerEnumsGenerator _getSwaggerEnumsGenerator(Map root) =>
+      _enumsMap[_getApiVersion(root)]!;
 
-  SwaggerModelsGenerator _getSwaggerModelsGenerator(String dartCode) =>
-      _modelsMap[_getApiVersion(dartCode)]!;
+  SwaggerModelsGenerator _getSwaggerModelsGenerator(Map root) =>
+      _modelsMap[_getApiVersion(root)]!;
 
-  SwaggerRequestsGenerator _getSwaggerRequestsGenerator(String dartCode) =>
+  SwaggerRequestsGenerator _getSwaggerRequestsGenerator(Map root) =>
       SwaggerRequestsGenerator();
 }
diff --git a/lib/swagger_dart_code_generator.dart b/lib/swagger_dart_code_generator.dart
index 92c090f9..f5517d0f 100644
--- a/lib/swagger_dart_code_generator.dart
+++ b/lib/swagger_dart_code_generator.dart
@@ -1,17 +1,21 @@
+import 'dart:convert';
+
 import 'package:build/build.dart';
 import 'package:swagger_dart_code_generator/src/extensions/file_name_extensions.dart';
+import 'package:swagger_dart_code_generator/src/extensions/yaml_extensions.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 import 'package:swagger_dart_code_generator/src/swagger_code_generator.dart';
 import 'package:universal_io/io.dart';
 import 'package:dart_style/dart_style.dart';
 import 'package:path/path.dart' show join, normalize;
 import 'package:http/http.dart' as http;
+import 'package:yaml/yaml.dart';
 
 ///Returns instance of SwaggerDartCodeGenerator
 SwaggerDartCodeGenerator swaggerCodeBuilder(BuilderOptions options) =>
     SwaggerDartCodeGenerator(options);
 
-const _inputFileExtensions = ['.swagger', '.json'];
+const _inputFileExtensions = ['.swagger', '.json', '.yaml'];
 
 const String _outputFileExtension = '.swagger.dart';
 const String _outputEnumsFileExtension = '.enums.swagger.dart';
@@ -19,7 +23,7 @@ const String _outputModelsFileExtension = '.models.swagger.dart';
 const String _outputResponsesFileExtension = '.responses.swagger.dart';
 const String _indexFileName = 'client_index.dart';
 const String _mappingFileName = 'client_mapping.dart';
-const kAdditionalResult = 'lib/swagger_dart_code_generator_temp.dart';
+const kAdditionalResult = 'swagger_dart_code_generator_temp.dart';
 
 String normal(String path) {
   return AssetId('', path).path;
@@ -32,7 +36,9 @@ Map<String, List<String>> _generateExtensions(GeneratorOptions options) {
       (FileSystemEntity file) =>
           _inputFileExtensions.any((ending) => file.path.endsWith(ending)));
 
-  File(kAdditionalResult).createSync();
+  final additionalResultPath = '${options.inputFolder}$kAdditionalResult';
+
+  File(additionalResultPath).createSync();
 
   var out = normalize(options.outputFolder);
 
@@ -41,27 +47,27 @@ Map<String, List<String>> _generateExtensions(GeneratorOptions options) {
     ...filesList.map((e) => e.path),
   ];
 
-  result[kAdditionalResult] = [];
+  result[additionalResultPath] = [];
 
   for (var url in allFilesPaths) {
     final name = getFileNameBase(url.split('/').last);
-    result[kAdditionalResult]!.add(join(out, '$name$_outputFileExtension'));
-    result[kAdditionalResult]!
+    result[additionalResultPath]!.add(join(out, '$name$_outputFileExtension'));
+    result[additionalResultPath]!
         .add(join(out, '$name$_outputEnumsFileExtension'));
-    result[kAdditionalResult]!
+    result[additionalResultPath]!
         .add(join(out, '$name$_outputModelsFileExtension'));
-    result[kAdditionalResult]!
+    result[additionalResultPath]!
         .add(join(out, '$name$_outputResponsesFileExtension'));
   }
 
   for (var url in options.inputUrls) {
-    result[kAdditionalResult]!
+    result[additionalResultPath]!
         .add(join(normalize(options.inputFolder), url.split('/').last));
   }
 
   ///Register additional outputs in first input
-  result[kAdditionalResult]!.add(join(out, _indexFileName));
-  result[kAdditionalResult]!.add(join(out, _mappingFileName));
+  result[additionalResultPath]!.add(join(out, _indexFileName));
+  result[additionalResultPath]!.add(join(out, _mappingFileName));
   return result;
 }
 
@@ -100,25 +106,37 @@ class SwaggerDartCodeGenerator implements Builder {
         .listSync()
         .where((FileSystemEntity file) =>
             _inputFileExtensions.any((ending) => file.path.endsWith(ending)))
-        .map((e) => e.path);
+        .map((e) => e.path)
+        .toList();
 
     await _generateAndWriteFiles(buildStep, filesList);
 
-    File(kAdditionalResult).deleteSync();
+    final additionalResultPath = '${options.inputFolder}$kAdditionalResult';
+
+    File(additionalResultPath).deleteSync();
   }
 
   Future<void> _generateAndWriteFiles(
-      BuildStep buildStep, Iterable<String> urls) async {
+      BuildStep buildStep, List<String> urls) async {
     for (final url in urls) {
       final file = File(url);
-      final contents = await file.readAsString();
+      var contents = await file.readAsString();
+
+      Map<String, dynamic> contentMap;
+
+      if (url.endsWith('.yaml')) {
+        final t = loadYaml(contents) as YamlMap;
+        contentMap = t.toMap();
+      } else {
+        contentMap = jsonDecode(contents) as Map<String, dynamic>;
+      }
 
       final fileNameWithExtension = url.split('/').last.replaceAll('-', '_');
 
       final fileNameWithoutExtension = getFileNameBase(fileNameWithExtension);
 
       await _generateAndWriteFile(
-        contents: contents,
+        contents: contentMap,
         buildStep: buildStep,
         fileNameWithExtension: fileNameWithExtension,
         fileNameWithoutExtension: fileNameWithoutExtension,
@@ -129,13 +147,14 @@ class SwaggerDartCodeGenerator implements Builder {
       buildStep.inputId,
       buildStep,
       true,
+      urls,
     );
 
     return;
   }
 
   Future<void> _generateAndWriteFile({
-    required String contents,
+    required Map<String, dynamic> contents,
     required String fileNameWithoutExtension,
     required String fileNameWithExtension,
     required BuildStep buildStep,
@@ -261,16 +280,16 @@ $dateToJson
     }
   }
 
-  Future<void> _generateAdditionalFiles(
-      AssetId inputId, BuildStep buildStep, bool hasModels) async {
+  Future<void> _generateAdditionalFiles(AssetId inputId, BuildStep buildStep,
+      bool hasModels, List<String> allFiles) async {
     final codeGenerator = SwaggerCodeGenerator();
 
     final indexAssetId =
         AssetId(inputId.package, join(options.outputFolder, _indexFileName));
 
-    final allFiles = buildExtensions.keys.toList();
-    allFiles.remove(kAdditionalResult);
-    allFiles.addAll(options.inputUrls);
+    //final additionalResultPath = '${options.inputFolder}$kAdditionalResult';
+
+    //allFiles.remove(additionalResultPath);
 
     final imports = codeGenerator.generateIndexes(allFiles);
 
diff --git a/pubspec.yaml b/pubspec.yaml
index fb415994..61299a76 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -24,6 +24,7 @@ dependencies:
   dart_style: ^2.2.1
   code_builder: ^4.1.0
   http: ^0.13.4
+  yaml: ^3.1.0
 
 dev_dependencies:
   build_runner: ^2.1.7


Test patch:
diff --git a/test/generator_tests/enums_generator_test.dart b/test/generator_tests/enums_generator_test.dart
index bbe475c5..f72627e7 100644
--- a/test/generator_tests/enums_generator_test.dart
+++ b/test/generator_tests/enums_generator_test.dart
@@ -1,3 +1,5 @@
+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';
@@ -22,8 +24,9 @@ void main() {
     // });
 
     test('Should generate enum from request parameter', () {
-      final result =
-          generator.generate(requestWithRnumInParameter, 'test_file');
+      final map =
+          jsonDecode(requestWithRnumInParameter) as Map<String, dynamic>;
+      final result = generator.generate(map, 'test_file');
 
       expect(result, contains('enum V3OrderOrderIdStatePutOrderStateRequest'));
     });
@@ -70,14 +73,15 @@ void main() {
     });
 
     test('Should remove numbers at beginning if it is key word', () {
-      final result =
-          SwaggerEnumsGenerator.getEnumNamesFromRequests(requestWithEnum);
+      final map = jsonDecode(requestWithEnum) as Map<String, dynamic>;
+      final result = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
       expect(result[0], equals('PetsPetIdItemsGetContentType'));
     });
 
     test('Should remove numbers at beginning if it is key word', () {
-      final result = SwaggerEnumsGenerator.getEnumNamesFromRequests(
-          requestWithListOfEnumInParameter);
+      final map =
+          jsonDecode(requestWithListOfEnumInParameter) as Map<String, dynamic>;
+      final result = SwaggerEnumsGenerator.getEnumNamesFromRequests(map);
       expect(result[0], equals('V3OrderOrderIdStatePutOrderStateRequest'));
     });
   });
diff --git a/test/generator_tests/models_generator_test.dart b/test/generator_tests/models_generator_test.dart
index 4e87fbf4..01675a8b 100644
--- a/test/generator_tests/models_generator_test.dart
+++ b/test/generator_tests/models_generator_test.dart
@@ -1,10 +1,11 @@
+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';
 import 'package:test/test.dart';
 import '../code_examples.dart';
-import 'test_data.dart';
 
 void main() {
   final generator = SwaggerModelsGeneratorV3();
@@ -13,16 +14,18 @@ void main() {
     const fileName = 'order_service.dart';
 
     test('Should parse object name as a field Type', () {
-      final result = generator.generate(modelWithParametersV3, fileName,
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final map = jsonDecode(modelWithParametersV3) as Map<String, dynamic>;
+      final result = generator.generate(
+          map, fileName, GeneratorOptions(inputFolder: '', outputFolder: ''));
 
       expect(
           result, contains('final enums.TokensResponseTokenType? tokenType'));
     });
 
     test('Should generate .toLower() when caseSensitive: false', () {
+      final map = jsonDecode(modelWithParametersV3) as Map<String, dynamic>;
       final result = generator.generate(
-          modelWithParametersV3,
+          map,
           fileName,
           GeneratorOptions(
               enumsCaseSensitive: false, inputFolder: '', outputFolder: ''));
@@ -34,8 +37,9 @@ void main() {
     });
 
     test('Should NOT generate .toLower() when caseSensitive: false', () {
+      final map = jsonDecode(modelWithParametersV3) as Map<String, dynamic>;
       final result = generator.generate(
-          modelWithParametersV3,
+          map,
           fileName,
           GeneratorOptions(
               enumsCaseSensitive: true, inputFolder: '', outputFolder: ''));
@@ -44,8 +48,9 @@ void main() {
     });
 
     test('Should parse object name as a field Type', () {
-      final result = generator2.generate(modelWithParametersV2, fileName,
-          GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final map = jsonDecode(modelWithParametersV2) as Map<String, dynamic>;
+      final result = generator2.generate(
+          map, fileName, GeneratorOptions(inputFolder: '', outputFolder: ''));
 
       expect(
           result,
@@ -55,6 +60,7 @@ 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(
@@ -65,8 +71,7 @@ void main() {
         inputFolder: '',
         outputFolder: '',
       );
-      final result =
-          generator.generate(modelWithParametersV3, fileName, generatorOptions);
+      final result = generator.generate(map, fileName, generatorOptions);
 
       expect(result, contains(expectedResult));
     });
@@ -324,7 +329,7 @@ void main() {
       const factoryConstructorExpectedResult =
           '\tfactory Animals.fromJson(Map<String, dynamic> json) => _\$AnimalsFromJson(json);\n';
       final result = generator.generateModelClassContent(
-          '',
+          {},
           className,
           map,
           {},
@@ -346,7 +351,7 @@ void main() {
       const factoryConstructorExpectedResult =
           '\tfactory Animals.fromJson(Map<String, dynamic> json) => _\$AnimalsFromJson(json);\n';
       final result = generator2.generateModelClassContent(
-          '',
+          {},
           className,
           map,
           {},
@@ -447,11 +452,12 @@ void main() {
       final map = <String, dynamic>{
         'Animals': <String, dynamic>{'\$ref': '#/definitions/Pet'}
       };
+
       const className = 'Animals';
       const jsonKeyExpectedResult = "\t@JsonKey(name: 'Animals')\n";
       const fieldExpectedResult = 'final Pet? animals';
       final result = generator.generatePropertiesContent(
-          carsService,
+          map,
           map,
           {},
           className,
@@ -476,7 +482,7 @@ void main() {
       const jsonKeyExpectedResult = "\t@JsonKey(name: 'Animals')\n";
       const fieldExpectedResult = 'final Pet? animals';
       final result = generator.generatePropertiesContent(
-          carsService,
+          map,
           map,
           {},
           className,
@@ -499,7 +505,7 @@ void main() {
       const jsonKeyExpectedResult = "\t@JsonKey(name: 'animals')\n";
       const fieldExpectedResult = 'final Pet? animals';
       final result = generator.generatePropertiesContent(
-          carsService,
+          map,
           map,
           {},
           className,
@@ -522,7 +528,7 @@ void main() {
       const jsonKeyExpectedResult = "\t@JsonKey(name: '\$with')\n";
       const fieldExpectedResult = 'final Pet? \$with';
       final result = generator.generatePropertiesContent(
-          carsService,
+          map,
           map,
           {},
           className,
@@ -705,22 +711,33 @@ void main() {
 
   group('Tests for generateResponses', () {
     test('Should generate empty string for V2', () {
-      final result = generator2.generateResponses(schemasResponsesWithResponse,
-          'fileName', GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final map =
+          jsonDecode(schemasResponsesWithResponse) as Map<String, dynamic>;
+      final result = generator2.generateResponses(
+          map,
+          'fileName',
+          GeneratorOptions(
+            inputFolder: '',
+            outputFolder: '',
+          ));
 
       expect(result, equals(''));
     });
 
     test('Should generate class from responses V3', () {
-      final result = generator.generateResponses(schemasResponsesWithResponse,
-          'fileName', GeneratorOptions(inputFolder: '', outputFolder: ''));
+      final map =
+          jsonDecode(schemasResponsesWithResponse) as Map<String, dynamic>;
+      final result = generator.generateResponses(
+          map, 'fileName', GeneratorOptions(inputFolder: '', outputFolder: ''));
 
       expect(result, contains('class SpaResponse'));
     });
 
     test('Should generate class from responses V3 and Schemas', () {
+      final map = jsonDecode(schemasResponsesWithResponseAndSchemas)
+          as Map<String, dynamic>;
       final result = generator.generateResponses(
-          schemasResponsesWithResponseAndSchemas,
+          map,
           'fileName',
           GeneratorOptions(
             inputFolder: '',
@@ -733,33 +750,42 @@ void main() {
 
   group('Tests for getAllEnumNames', () {
     test('Should', () {
-      final result = generator2.getAllEnumNames(enumAsDefinitionV2);
+      final map = jsonDecode(enumAsDefinitionV2) as Map<String, dynamic>;
+      final result = generator2.getAllEnumNames(map);
 
       expect(result, contains('enums.SpaResponse'));
     });
 
     test('Should get enum name from schemas', () {
-      final result = generator.getAllEnumNames(schemasWithEnumsInProperties);
+      final map =
+          jsonDecode(schemasWithEnumsInProperties) as Map<String, dynamic>;
+      final result = generator.getAllEnumNames(map);
 
       expect(result, contains('enums.SpaSchemaSuccessValues'));
     });
 
     test('Should get enum name from responses', () {
-      final result = generator.getAllEnumNames(schemasWithEnumsInProperties);
+      final map =
+          jsonDecode(schemasWithEnumsInProperties) as Map<String, dynamic>;
+      final result = generator.getAllEnumNames(map);
 
       expect(result, contains('enums.SpaResponse'));
     });
 
     test('Should get enum name from responses with Enum items', () {
-      final result = generator.getAllEnumNames(schemasWithEnumsInProperties);
+      final map =
+          jsonDecode(schemasWithEnumsInProperties) as Map<String, dynamic>;
+      final result = generator.getAllEnumNames(map);
 
       expect(result, contains('enums.SpaEnumResponseFailedValued'));
     });
   });
   group('Tests for models from responses', () {
     test('Should generate correct model from response', () {
+      final map =
+          jsonDecode(requestWithReturnTypeInjected) as Map<String, dynamic>;
       final result = generator.generate(
-          requestWithReturnTypeInjected,
+          map,
           'my_service',
           GeneratorOptions(
             inputFolder: '',
diff --git a/test/generator_tests/requests_generator_test.dart b/test/generator_tests/requests_generator_test.dart
index b1b10f63..157d2a1a 100644
--- a/test/generator_tests/requests_generator_test.dart
+++ b/test/generator_tests/requests_generator_test.dart
@@ -1,3 +1,5 @@
+import 'dart:convert';
+
 import 'package:swagger_dart_code_generator/src/code_generators/swagger_requests_generator.dart';
 import 'package:swagger_dart_code_generator/src/models/generator_options.dart';
 import 'package:test/test.dart';
@@ -8,9 +10,11 @@ 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(
-        code: carsService,
+        map: map,
         className: 'CarsService',
         fileName: 'cars_service',
         options: GeneratorOptions(
@@ -28,7 +32,7 @@ void main() {
       );
 
       final result2 = generator.generate(
-        code: carsService,
+        map: map,
         className: 'CarsService',
         fileName: 'cars_service',
         options: GeneratorOptions(