From e950c27ec362b0bdc32f706e3da35967f111d09a Mon Sep 17 00:00:00 2001
From: agilob <info@agilob.net>
Date: Tue, 23 Jun 2020 09:48:32 +0100
Subject: [PATCH 1/2] Dart - generate constructor with names params

---
 .../src/main/resources/dart2/class.mustache          |  7 ++++++-
 .../petstore_client_lib/lib/model/api_response.dart  |  7 ++++++-
 .../petstore_client_lib/lib/model/category.dart      |  6 +++++-
 .../dart2/petstore_client_lib/lib/model/order.dart   | 10 +++++++++-
 .../dart2/petstore_client_lib/lib/model/pet.dart     | 10 +++++++++-
 .../dart2/petstore_client_lib/lib/model/tag.dart     |  6 +++++-
 .../dart2/petstore_client_lib/lib/model/user.dart    | 12 +++++++++++-
 7 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/class.mustache
index d64dc80606a..6c7eca10552 100644
--- a/modules/openapi-generator/src/main/resources/dart2/class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/class.mustache
@@ -6,7 +6,12 @@ class {{classname}} {
   {{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
   {{/allowableValues}}
   {{/vars}}
-  {{classname}}();
+
+  {{classname}}({
+  {{#vars}}
+    this.{{name}},
+  {{/vars}}
+  });
 
   @override
   String toString() {
diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart
index c5b6886be8b..ddc3cafb99d 100644
--- a/samples/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart
+++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart
@@ -7,7 +7,12 @@ class ApiResponse {
   String type = null;
   
   String message = null;
-  ApiResponse();
+
+  ApiResponse({
+    this.code,
+    this.type,
+    this.message,
+  });
 
   @override
   String toString() {
diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/category.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/category.dart
index 686ad33cac8..3bcb27396bc 100644
--- a/samples/client/petstore/dart2/petstore_client_lib/lib/model/category.dart
+++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/category.dart
@@ -5,7 +5,11 @@ class Category {
   int id = null;
   
   String name = null;
-  Category();
+
+  Category({
+    this.id,
+    this.name,
+  });
 
   @override
   String toString() {
diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/order.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/order.dart
index 34370b21e3b..f313282411e 100644
--- a/samples/client/petstore/dart2/petstore_client_lib/lib/model/order.dart
+++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/order.dart
@@ -14,7 +14,15 @@ class Order {
   //enum statusEnum {  placed,  approved,  delivered,  };{
   
   bool complete = false;
-  Order();
+
+  Order({
+    this.id,
+    this.petId,
+    this.quantity,
+    this.shipDate,
+    this.status,
+    this.complete,
+  });
 
   @override
   String toString() {
diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart
index 92a096c4027..4b9c7869e65 100644
--- a/samples/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart
+++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart
@@ -14,7 +14,15 @@ class Pet {
   /* pet status in the store */
   String status = null;
   //enum statusEnum {  available,  pending,  sold,  };{
-  Pet();
+
+  Pet({
+    this.id,
+    this.category,
+    this.name,
+    this.photoUrls,
+    this.tags,
+    this.status,
+  });
 
   @override
   String toString() {
diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart
index 5b758c01b7a..743382dc408 100644
--- a/samples/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart
+++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart
@@ -5,7 +5,11 @@ class Tag {
   int id = null;
   
   String name = null;
-  Tag();
+
+  Tag({
+    this.id,
+    this.name,
+  });
 
   @override
   String toString() {
diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/user.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/user.dart
index 685ffadb4ee..b7ce4924183 100644
--- a/samples/client/petstore/dart2/petstore_client_lib/lib/model/user.dart
+++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/user.dart
@@ -17,7 +17,17 @@ class User {
   String phone = null;
   /* User Status */
   int userStatus = null;
-  User();
+
+  User({
+    this.id,
+    this.username,
+    this.firstName,
+    this.lastName,
+    this.email,
+    this.password,
+    this.phone,
+    this.userStatus,
+  });
 
   @override
   String toString() {
-- 
GitLab


From db150b9f26cb0909e8f0e913b0d72ab871240560 Mon Sep 17 00:00:00 2001
From: agilob <info@agilob.net>
Date: Tue, 23 Jun 2020 09:50:34 +0100
Subject: [PATCH 2/2] Test if constructor exists

---
 .../client/petstore/dart2/petstore/test/pet_test.dart | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/samples/client/petstore/dart2/petstore/test/pet_test.dart b/samples/client/petstore/dart2/petstore/test/pet_test.dart
index b978022e565..5898c221607 100644
--- a/samples/client/petstore/dart2/petstore/test/pet_test.dart
+++ b/samples/client/petstore/dart2/petstore/test/pet_test.dart
@@ -25,11 +25,12 @@ void main() {
         ..id = 124321
         ..name = 'Jose'
     ];
-    return Pet()
-      ..id = id
-      ..category = category
-      ..tags = tags
-      ..name = name
+    return Pet(
+      id : id,
+      category: category,
+      tags: tags,
+      name: name,
+    )
       ..status = status
       ..photoUrls = ['https://petstore.com/sample/photo1.jpg'];
   }
-- 
GitLab