diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/class.mustache index d64dc80606aa..6c7eca10552a 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/test/pet_test.dart b/samples/client/petstore/dart2/petstore/test/pet_test.dart index b978022e5651..5898c221607c 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']; } 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 c5b6886be8b2..ddc3cafb99db 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 686ad33cac82..3bcb27396bc5 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 34370b21e3b8..f313282411e8 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 92a096c4027d..4b9c7869e656 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 5b758c01b7af..743382dc408b 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 685ffadb4ee7..b7ce4924183c 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() {