Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions modules/openapi-generator/src/main/resources/dart/class.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agilob Can we keep the indentation as 2-space? It would make the code review a lot easier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MR will cause a bunch of conflicts with 2 other MR I have in progress and it's not my changes, I resurrected commit from
@arndt-s. I will take care of it as the last thing if you dont mind?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with taking care of the code indentation in another PR.

{{/isDate}}
{{/isDateTime}}
{{/vars}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class ApiResponse {

Map<String, dynamic> toJson() {
return {
'code': code,
'type': type,
'message': message
'code': code,
'type': type,
'message': message
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Category {

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
'id': id,
'name': name
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class InlineObject {

Map<String, dynamic> toJson() {
return {
'name': name,
'status': status
'name': name,
'status': status
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class InlineObject1 {

Map<String, dynamic> toJson() {
return {
'additionalMetadata': additionalMetadata,
'file': file
'additionalMetadata': additionalMetadata,
'file': file == null ? null : file.toJson()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class Order {

Map<String, dynamic> 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
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class Pet {

Map<String, dynamic> 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
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Tag {

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
'id': id,
'name': name
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ class User {

Map<String, dynamic> 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
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class ApiResponse {

Map<String, dynamic> toJson() {
return {
'code': code,
'type': type,
'message': message
'code': code,
'type': type,
'message': message
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Category {

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
'id': id,
'name': name
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class Order {

Map<String, dynamic> 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
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class Pet {

Map<String, dynamic> 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
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Tag {

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
'id': id,
'name': name
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ class User {

Map<String, dynamic> 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
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class ApiResponse {

Map<String, dynamic> toJson() {
return {
'code': code,
'type': type,
'message': message
'code': code,
'type': type,
'message': message
};
}

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/dart/openapi/lib/model/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Category {

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
'id': id,
'name': name
};
}

Expand Down
12 changes: 6 additions & 6 deletions samples/client/petstore/dart/openapi/lib/model/order.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class Order {

Map<String, dynamic> 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
};
}

Expand Down
12 changes: 6 additions & 6 deletions samples/client/petstore/dart/openapi/lib/model/pet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class Pet {

Map<String, dynamic> 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
};
}

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/dart/openapi/lib/model/tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Tag {

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
'id': id,
'name': name
};
}

Expand Down
16 changes: 8 additions & 8 deletions samples/client/petstore/dart/openapi/lib/model/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ class User {

Map<String, dynamic> 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
};
}

Expand Down