Skip to content

Commit 58e43ce

Browse files
ircechowing328
authored andcommitted
[DART2] Maps could not be deserialized in dart 2 (#1007)
* fix[dart2]: due to stronger type checking in dart 2, maps could not be deserialized * rebuild dart2 petstore
1 parent fc35bb1 commit 58e43ce

File tree

19 files changed

+50
-59
lines changed

19 files changed

+50
-59
lines changed

modules/openapi-generator/src/main/resources/dart2/class.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class {{classname}} {
7272
return json == null ? new List<{{classname}}>() : json.map((value) => new {{classname}}.fromJson(value)).toList();
7373
}
7474

75-
static Map<String, {{classname}}> mapFromJson(Map<String, Map<String, dynamic>> json) {
75+
static Map<String, {{classname}}> mapFromJson(Map<String, dynamic> json) {
7676
var map = new Map<String, {{classname}}>();
7777
if (json != null && json.length > 0) {
78-
json.forEach((String key, Map<String, dynamic> value) => map[key] = new {{classname}}.fromJson(value));
78+
json.forEach((String key, dynamic value) => map[key] = new {{classname}}.fromJson(value));
7979
}
8080
return map;
8181
}

samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ class ApiResponse {
3030
: json.map((value) => new ApiResponse.fromJson(value)).toList();
3131
}
3232

33-
static Map<String, ApiResponse> mapFromJson(
34-
Map<String, Map<String, dynamic>> json) {
33+
static Map<String, ApiResponse> mapFromJson(Map<String, dynamic> json) {
3534
var map = new Map<String, ApiResponse>();
3635
if (json != null && json.length > 0) {
37-
json.forEach((String key, Map<String, dynamic> value) =>
36+
json.forEach((String key, dynamic value) =>
3837
map[key] = new ApiResponse.fromJson(value));
3938
}
4039
return map;

samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ class Category {
2727
: json.map((value) => new Category.fromJson(value)).toList();
2828
}
2929

30-
static Map<String, Category> mapFromJson(
31-
Map<String, Map<String, dynamic>> json) {
30+
static Map<String, Category> mapFromJson(Map<String, dynamic> json) {
3231
var map = new Map<String, Category>();
3332
if (json != null && json.length > 0) {
34-
json.forEach((String key, Map<String, dynamic> value) =>
33+
json.forEach((String key, dynamic value) =>
3534
map[key] = new Category.fromJson(value));
3635
}
3736
return map;

samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ class Order {
4848
: json.map((value) => new Order.fromJson(value)).toList();
4949
}
5050

51-
static Map<String, Order> mapFromJson(
52-
Map<String, Map<String, dynamic>> json) {
51+
static Map<String, Order> mapFromJson(Map<String, dynamic> json) {
5352
var map = new Map<String, Order>();
5453
if (json != null && json.length > 0) {
55-
json.forEach((String key, Map<String, dynamic> value) =>
56-
map[key] = new Order.fromJson(value));
54+
json.forEach(
55+
(String key, dynamic value) => map[key] = new Order.fromJson(value));
5756
}
5857
return map;
5958
}

samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ class Pet {
4949
: json.map((value) => new Pet.fromJson(value)).toList();
5050
}
5151

52-
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
52+
static Map<String, Pet> mapFromJson(Map<String, dynamic> json) {
5353
var map = new Map<String, Pet>();
5454
if (json != null && json.length > 0) {
55-
json.forEach((String key, Map<String, dynamic> value) =>
56-
map[key] = new Pet.fromJson(value));
55+
json.forEach(
56+
(String key, dynamic value) => map[key] = new Pet.fromJson(value));
5757
}
5858
return map;
5959
}

samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class Tag {
2727
: json.map((value) => new Tag.fromJson(value)).toList();
2828
}
2929

30-
static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
30+
static Map<String, Tag> mapFromJson(Map<String, dynamic> json) {
3131
var map = new Map<String, Tag>();
3232
if (json != null && json.length > 0) {
33-
json.forEach((String key, Map<String, dynamic> value) =>
34-
map[key] = new Tag.fromJson(value));
33+
json.forEach(
34+
(String key, dynamic value) => map[key] = new Tag.fromJson(value));
3535
}
3636
return map;
3737
}

samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class User {
5454
: json.map((value) => new User.fromJson(value)).toList();
5555
}
5656

57-
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
57+
static Map<String, User> mapFromJson(Map<String, dynamic> json) {
5858
var map = new Map<String, User>();
5959
if (json != null && json.length > 0) {
60-
json.forEach((String key, Map<String, dynamic> value) =>
61-
map[key] = new User.fromJson(value));
60+
json.forEach(
61+
(String key, dynamic value) => map[key] = new User.fromJson(value));
6262
}
6363
return map;
6464
}

samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ class ApiResponse {
3030
: json.map((value) => new ApiResponse.fromJson(value)).toList();
3131
}
3232

33-
static Map<String, ApiResponse> mapFromJson(
34-
Map<String, Map<String, dynamic>> json) {
33+
static Map<String, ApiResponse> mapFromJson(Map<String, dynamic> json) {
3534
var map = new Map<String, ApiResponse>();
3635
if (json != null && json.length > 0) {
37-
json.forEach((String key, Map<String, dynamic> value) =>
36+
json.forEach((String key, dynamic value) =>
3837
map[key] = new ApiResponse.fromJson(value));
3938
}
4039
return map;

samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ class Category {
2727
: json.map((value) => new Category.fromJson(value)).toList();
2828
}
2929

30-
static Map<String, Category> mapFromJson(
31-
Map<String, Map<String, dynamic>> json) {
30+
static Map<String, Category> mapFromJson(Map<String, dynamic> json) {
3231
var map = new Map<String, Category>();
3332
if (json != null && json.length > 0) {
34-
json.forEach((String key, Map<String, dynamic> value) =>
33+
json.forEach((String key, dynamic value) =>
3534
map[key] = new Category.fromJson(value));
3635
}
3736
return map;

samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ class Order {
4848
: json.map((value) => new Order.fromJson(value)).toList();
4949
}
5050

51-
static Map<String, Order> mapFromJson(
52-
Map<String, Map<String, dynamic>> json) {
51+
static Map<String, Order> mapFromJson(Map<String, dynamic> json) {
5352
var map = new Map<String, Order>();
5453
if (json != null && json.length > 0) {
55-
json.forEach((String key, Map<String, dynamic> value) =>
56-
map[key] = new Order.fromJson(value));
54+
json.forEach(
55+
(String key, dynamic value) => map[key] = new Order.fromJson(value));
5756
}
5857
return map;
5958
}

samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ class Pet {
4949
: json.map((value) => new Pet.fromJson(value)).toList();
5050
}
5151

52-
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
52+
static Map<String, Pet> mapFromJson(Map<String, dynamic> json) {
5353
var map = new Map<String, Pet>();
5454
if (json != null && json.length > 0) {
55-
json.forEach((String key, Map<String, dynamic> value) =>
56-
map[key] = new Pet.fromJson(value));
55+
json.forEach(
56+
(String key, dynamic value) => map[key] = new Pet.fromJson(value));
5757
}
5858
return map;
5959
}

samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class Tag {
2727
: json.map((value) => new Tag.fromJson(value)).toList();
2828
}
2929

30-
static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
30+
static Map<String, Tag> mapFromJson(Map<String, dynamic> json) {
3131
var map = new Map<String, Tag>();
3232
if (json != null && json.length > 0) {
33-
json.forEach((String key, Map<String, dynamic> value) =>
34-
map[key] = new Tag.fromJson(value));
33+
json.forEach(
34+
(String key, dynamic value) => map[key] = new Tag.fromJson(value));
3535
}
3636
return map;
3737
}

samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class User {
5454
: json.map((value) => new User.fromJson(value)).toList();
5555
}
5656

57-
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
57+
static Map<String, User> mapFromJson(Map<String, dynamic> json) {
5858
var map = new Map<String, User>();
5959
if (json != null && json.length > 0) {
60-
json.forEach((String key, Map<String, dynamic> value) =>
61-
map[key] = new User.fromJson(value));
60+
json.forEach(
61+
(String key, dynamic value) => map[key] = new User.fromJson(value));
6262
}
6363
return map;
6464
}

samples/client/petstore/dart2/openapi/lib/model/api_response.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ class ApiResponse {
3030
: json.map((value) => new ApiResponse.fromJson(value)).toList();
3131
}
3232

33-
static Map<String, ApiResponse> mapFromJson(
34-
Map<String, Map<String, dynamic>> json) {
33+
static Map<String, ApiResponse> mapFromJson(Map<String, dynamic> json) {
3534
var map = new Map<String, ApiResponse>();
3635
if (json != null && json.length > 0) {
37-
json.forEach((String key, Map<String, dynamic> value) =>
36+
json.forEach((String key, dynamic value) =>
3837
map[key] = new ApiResponse.fromJson(value));
3938
}
4039
return map;

samples/client/petstore/dart2/openapi/lib/model/category.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ class Category {
2727
: json.map((value) => new Category.fromJson(value)).toList();
2828
}
2929

30-
static Map<String, Category> mapFromJson(
31-
Map<String, Map<String, dynamic>> json) {
30+
static Map<String, Category> mapFromJson(Map<String, dynamic> json) {
3231
var map = new Map<String, Category>();
3332
if (json != null && json.length > 0) {
34-
json.forEach((String key, Map<String, dynamic> value) =>
33+
json.forEach((String key, dynamic value) =>
3534
map[key] = new Category.fromJson(value));
3635
}
3736
return map;

samples/client/petstore/dart2/openapi/lib/model/order.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ class Order {
4848
: json.map((value) => new Order.fromJson(value)).toList();
4949
}
5050

51-
static Map<String, Order> mapFromJson(
52-
Map<String, Map<String, dynamic>> json) {
51+
static Map<String, Order> mapFromJson(Map<String, dynamic> json) {
5352
var map = new Map<String, Order>();
5453
if (json != null && json.length > 0) {
55-
json.forEach((String key, Map<String, dynamic> value) =>
56-
map[key] = new Order.fromJson(value));
54+
json.forEach(
55+
(String key, dynamic value) => map[key] = new Order.fromJson(value));
5756
}
5857
return map;
5958
}

samples/client/petstore/dart2/openapi/lib/model/pet.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ class Pet {
4949
: json.map((value) => new Pet.fromJson(value)).toList();
5050
}
5151

52-
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
52+
static Map<String, Pet> mapFromJson(Map<String, dynamic> json) {
5353
var map = new Map<String, Pet>();
5454
if (json != null && json.length > 0) {
55-
json.forEach((String key, Map<String, dynamic> value) =>
56-
map[key] = new Pet.fromJson(value));
55+
json.forEach(
56+
(String key, dynamic value) => map[key] = new Pet.fromJson(value));
5757
}
5858
return map;
5959
}

samples/client/petstore/dart2/openapi/lib/model/tag.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class Tag {
2727
: json.map((value) => new Tag.fromJson(value)).toList();
2828
}
2929

30-
static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
30+
static Map<String, Tag> mapFromJson(Map<String, dynamic> json) {
3131
var map = new Map<String, Tag>();
3232
if (json != null && json.length > 0) {
33-
json.forEach((String key, Map<String, dynamic> value) =>
34-
map[key] = new Tag.fromJson(value));
33+
json.forEach(
34+
(String key, dynamic value) => map[key] = new Tag.fromJson(value));
3535
}
3636
return map;
3737
}

samples/client/petstore/dart2/openapi/lib/model/user.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class User {
5454
: json.map((value) => new User.fromJson(value)).toList();
5555
}
5656

57-
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
57+
static Map<String, User> mapFromJson(Map<String, dynamic> json) {
5858
var map = new Map<String, User>();
5959
if (json != null && json.length > 0) {
60-
json.forEach((String key, Map<String, dynamic> value) =>
61-
map[key] = new User.fromJson(value));
60+
json.forEach(
61+
(String key, dynamic value) => map[key] = new User.fromJson(value));
6262
}
6363
return map;
6464
}

0 commit comments

Comments
 (0)