diff --git a/modules/openapi-generator/src/main/resources/dart/class.mustache b/modules/openapi-generator/src/main/resources/dart/class.mustache index 64726de30675..b69af46ffaa9 100644 --- a/modules/openapi-generator/src/main/resources/dart/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart/class.mustache @@ -58,14 +58,24 @@ class {{classname}} { return { {{#vars}} {{#isDateTime}} - '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} + '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} {{/isDateTime}} {{#isDate}} - '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} + '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} {{/isDate}} {{^isDateTime}} {{^isDate}} - '{{baseName}}': {{name}}{{^-last}},{{/-last}} + {{#complexType}} + {{#isListContainer}} + '{{baseName}}': {{name}} == null ? null : {{name}}.map((item) => item.toJson()).toList(){{^-last}},{{/-last}} + {{/isListContainer}} + {{^isListContainer}} + '{{baseName}}': {{name}} == null ? null : {{name}}.toJson(){{^-last}},{{/-last}} + {{/isListContainer}} + {{/complexType}} + {{^complexType}} + '{{baseName}}': {{name}}{{^-last}},{{/-last}} + {{/complexType}} {{/isDate}} {{/isDateTime}} {{/vars}} diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart index f2fddde347ae..07ab760f4f8c 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart @@ -35,9 +35,9 @@ class ApiResponse { Map toJson() { return { - 'code': code, - 'type': type, - 'message': message + 'code': code, + 'type': type, + 'message': message }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart index 1750c6a0acb1..817df42fa46c 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart @@ -28,8 +28,8 @@ class Category { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart index 01da636b114a..70b56f81369f 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart @@ -28,8 +28,8 @@ class InlineObject { Map toJson() { return { - 'name': name, - 'status': status + 'name': name, + 'status': status }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart index 9a50a7b88be3..f0a458ab2802 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart @@ -28,8 +28,8 @@ class InlineObject1 { Map toJson() { return { - 'additionalMetadata': additionalMetadata, - 'file': file + 'additionalMetadata': additionalMetadata, + 'file': file == null ? null : file.toJson() }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart index 51d15f730415..6bd66bb554a3 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart @@ -57,12 +57,12 @@ class Order { Map toJson() { return { - 'id': id, - 'petId': petId, - 'quantity': quantity, - 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), - 'status': status, - 'complete': complete + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart index c64406368d87..30db0ebc8417 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart @@ -57,12 +57,12 @@ class Pet { Map toJson() { return { - 'id': id, - 'category': category, - 'name': name, - 'photoUrls': photoUrls, - 'tags': tags, - 'status': status + 'id': id, + 'category': category == null ? null : category.toJson(), + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags == null ? null : tags.map((item) => item.toJson()).toList(), + 'status': status }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart index 980c6e016302..4657fde0d393 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart @@ -28,8 +28,8 @@ class Tag { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart index 1555eb0a3ef5..41ed8d742f1d 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart @@ -70,14 +70,14 @@ class User { Map toJson() { return { - 'id': id, - 'username': username, - 'firstName': firstName, - 'lastName': lastName, - 'email': email, - 'password': password, - 'phone': phone, - 'userStatus': userStatus + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus }; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart index f2fddde347ae..07ab760f4f8c 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart @@ -35,9 +35,9 @@ class ApiResponse { Map toJson() { return { - 'code': code, - 'type': type, - 'message': message + 'code': code, + 'type': type, + 'message': message }; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart index 1750c6a0acb1..817df42fa46c 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart @@ -28,8 +28,8 @@ class Category { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart index 51d15f730415..6bd66bb554a3 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart @@ -57,12 +57,12 @@ class Order { Map toJson() { return { - 'id': id, - 'petId': petId, - 'quantity': quantity, - 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), - 'status': status, - 'complete': complete + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete }; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart index c64406368d87..30db0ebc8417 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart @@ -57,12 +57,12 @@ class Pet { Map toJson() { return { - 'id': id, - 'category': category, - 'name': name, - 'photoUrls': photoUrls, - 'tags': tags, - 'status': status + 'id': id, + 'category': category == null ? null : category.toJson(), + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags == null ? null : tags.map((item) => item.toJson()).toList(), + 'status': status }; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart index 980c6e016302..4657fde0d393 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart @@ -28,8 +28,8 @@ class Tag { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart index 1555eb0a3ef5..41ed8d742f1d 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart @@ -70,14 +70,14 @@ class User { Map toJson() { return { - 'id': id, - 'username': username, - 'firstName': firstName, - 'lastName': lastName, - 'email': email, - 'password': password, - 'phone': phone, - 'userStatus': userStatus + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/api_response.dart b/samples/client/petstore/dart/openapi/lib/model/api_response.dart index f2fddde347ae..07ab760f4f8c 100644 --- a/samples/client/petstore/dart/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/openapi/lib/model/api_response.dart @@ -35,9 +35,9 @@ class ApiResponse { Map toJson() { return { - 'code': code, - 'type': type, - 'message': message + 'code': code, + 'type': type, + 'message': message }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/category.dart b/samples/client/petstore/dart/openapi/lib/model/category.dart index 1750c6a0acb1..817df42fa46c 100644 --- a/samples/client/petstore/dart/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/openapi/lib/model/category.dart @@ -28,8 +28,8 @@ class Category { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/order.dart b/samples/client/petstore/dart/openapi/lib/model/order.dart index 51d15f730415..6bd66bb554a3 100644 --- a/samples/client/petstore/dart/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/openapi/lib/model/order.dart @@ -57,12 +57,12 @@ class Order { Map toJson() { return { - 'id': id, - 'petId': petId, - 'quantity': quantity, - 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), - 'status': status, - 'complete': complete + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/pet.dart b/samples/client/petstore/dart/openapi/lib/model/pet.dart index c64406368d87..30db0ebc8417 100644 --- a/samples/client/petstore/dart/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/openapi/lib/model/pet.dart @@ -57,12 +57,12 @@ class Pet { Map toJson() { return { - 'id': id, - 'category': category, - 'name': name, - 'photoUrls': photoUrls, - 'tags': tags, - 'status': status + 'id': id, + 'category': category == null ? null : category.toJson(), + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags == null ? null : tags.map((item) => item.toJson()).toList(), + 'status': status }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/tag.dart b/samples/client/petstore/dart/openapi/lib/model/tag.dart index 980c6e016302..4657fde0d393 100644 --- a/samples/client/petstore/dart/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/openapi/lib/model/tag.dart @@ -28,8 +28,8 @@ class Tag { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/user.dart b/samples/client/petstore/dart/openapi/lib/model/user.dart index 1555eb0a3ef5..41ed8d742f1d 100644 --- a/samples/client/petstore/dart/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/openapi/lib/model/user.dart @@ -70,14 +70,14 @@ class User { Map toJson() { return { - 'id': id, - 'username': username, - 'firstName': firstName, - 'lastName': lastName, - 'email': email, - 'password': password, - 'phone': phone, - 'userStatus': userStatus + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus }; }