Skip to content

Commit 025d452

Browse files
d3v-clwing328
authored andcommitted
[DART2]: fix Map<String, nativeType> fromJson (OpenAPITools#1936)
1 parent 02bcf9b commit 025d452

File tree

93 files changed

+3489
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3489
-366
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ class {{classname}} {
4242
{{/complexType}}
4343
{{^complexType}}
4444
{{#isListContainer}}
45-
{{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList();
45+
{{name}} = (json['{{baseName}}'] as List).cast<{{items.datatype}}>();
4646
{{/isListContainer}}
4747
{{^isListContainer}}
48-
{{name}} = json['{{baseName}}'];
48+
{{#isMapContainer}}
49+
{{name}} = (json['{{baseName}}'] as Map).cast<String, {{items.datatype}}>();
50+
{{/isMapContainer}}
51+
{{^isMapContainer}}
52+
{{name}} = json['{{baseName}}'];
53+
{{/isMapContainer}}
4954
{{/isListContainer}}
5055
{{/complexType}}
5156
{{/isDate}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1-SNAPSHOT
1+
4.0.0-SNAPSHOT

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke
44
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
55

66
- API version: 1.0.0
7-
- Build date: 2018-12-02T16:16:44.701611+01:00[Europe/Paris]
7+
- Build date: 2019-01-17T18:23:25.026381+01:00[Europe/Vienna]
88
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
99

1010
## Requirements
@@ -57,10 +57,10 @@ import 'package:openapi/api.dart';
5757
5858
final jaguarApiGen = JaguarApiGen();
5959
var api_instance = jaguarApiGen.getPetApi();
60-
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
60+
var body = new Pet(); // Pet | Pet object that needs to be added to the store
6161
6262
try {
63-
api_instance.addPet(pet);
63+
api_instance.addPet(body);
6464
} catch (e) {
6565
print("Exception when calling PetApi->addPet: $e\n");
6666
}

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/docs/PetApi.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Method | HTTP request | Description
2020

2121

2222
# **addPet**
23-
> addPet(pet)
23+
> addPet(body)
2424
2525
Add a new pet to the store
2626

@@ -31,10 +31,10 @@ import 'package:openapi/api.dart';
3131
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
3232
3333
var api_instance = new PetApi();
34-
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
34+
var body = new Pet(); // Pet | Pet object that needs to be added to the store
3535
3636
try {
37-
api_instance.addPet(pet);
37+
api_instance.addPet(body);
3838
} catch (e) {
3939
print("Exception when calling PetApi->addPet: $e\n");
4040
}
@@ -44,7 +44,7 @@ try {
4444

4545
Name | Type | Description | Notes
4646
------------- | ------------- | ------------- | -------------
47-
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
47+
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
4848

4949
### Return type
5050

@@ -243,7 +243,7 @@ Name | Type | Description | Notes
243243
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
244244

245245
# **updatePet**
246-
> updatePet(pet)
246+
> updatePet(body)
247247
248248
Update an existing pet
249249

@@ -254,10 +254,10 @@ import 'package:openapi/api.dart';
254254
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
255255
256256
var api_instance = new PetApi();
257-
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
257+
var body = new Pet(); // Pet | Pet object that needs to be added to the store
258258
259259
try {
260-
api_instance.updatePet(pet);
260+
api_instance.updatePet(body);
261261
} catch (e) {
262262
print("Exception when calling PetApi->updatePet: $e\n");
263263
}
@@ -267,7 +267,7 @@ try {
267267

268268
Name | Type | Description | Notes
269269
------------- | ------------- | ------------- | -------------
270-
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
270+
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
271271

272272
### Return type
273273

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/docs/StoreApi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ No authorization required
144144
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
145145

146146
# **placeOrder**
147-
> Order placeOrder(order)
147+
> Order placeOrder(body)
148148
149149
Place an order for a pet
150150

@@ -153,10 +153,10 @@ Place an order for a pet
153153
import 'package:openapi/api.dart';
154154
155155
var api_instance = new StoreApi();
156-
var order = new Order(); // Order | order placed for purchasing the pet
156+
var body = new Order(); // Order | order placed for purchasing the pet
157157
158158
try {
159-
var result = api_instance.placeOrder(order);
159+
var result = api_instance.placeOrder(body);
160160
print(result);
161161
} catch (e) {
162162
print("Exception when calling StoreApi->placeOrder: $e\n");
@@ -167,7 +167,7 @@ try {
167167

168168
Name | Type | Description | Notes
169169
------------- | ------------- | ------------- | -------------
170-
**order** | [**Order**](Order.md)| order placed for purchasing the pet |
170+
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
171171

172172
### Return type
173173

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/docs/UserApi.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Method | HTTP request | Description
2020

2121

2222
# **createUser**
23-
> createUser(user)
23+
> createUser(body)
2424
2525
Create user
2626

@@ -31,10 +31,10 @@ This can only be done by the logged in user.
3131
import 'package:openapi/api.dart';
3232
3333
var api_instance = new UserApi();
34-
var user = new User(); // User | Created user object
34+
var body = new User(); // User | Created user object
3535
3636
try {
37-
api_instance.createUser(user);
37+
api_instance.createUser(body);
3838
} catch (e) {
3939
print("Exception when calling UserApi->createUser: $e\n");
4040
}
@@ -44,7 +44,7 @@ try {
4444

4545
Name | Type | Description | Notes
4646
------------- | ------------- | ------------- | -------------
47-
**user** | [**User**](User.md)| Created user object |
47+
**body** | [**User**](User.md)| Created user object |
4848

4949
### Return type
5050

@@ -62,7 +62,7 @@ No authorization required
6262
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6363

6464
# **createUsersWithArrayInput**
65-
> createUsersWithArrayInput(user)
65+
> createUsersWithArrayInput(body)
6666
6767
Creates list of users with given input array
6868

@@ -71,10 +71,10 @@ Creates list of users with given input array
7171
import 'package:openapi/api.dart';
7272
7373
var api_instance = new UserApi();
74-
var user = [new List&lt;User&gt;()]; // List<User> | List of user object
74+
var body = [new List&lt;User&gt;()]; // List<User> | List of user object
7575
7676
try {
77-
api_instance.createUsersWithArrayInput(user);
77+
api_instance.createUsersWithArrayInput(body);
7878
} catch (e) {
7979
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
8080
}
@@ -84,7 +84,7 @@ try {
8484

8585
Name | Type | Description | Notes
8686
------------- | ------------- | ------------- | -------------
87-
**user** | [**List&lt;User&gt;**](List.md)| List of user object |
87+
**body** | [**List&lt;User&gt;**](List.md)| List of user object |
8888

8989
### Return type
9090

@@ -102,7 +102,7 @@ No authorization required
102102
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
103103

104104
# **createUsersWithListInput**
105-
> createUsersWithListInput(user)
105+
> createUsersWithListInput(body)
106106
107107
Creates list of users with given input array
108108

@@ -111,10 +111,10 @@ Creates list of users with given input array
111111
import 'package:openapi/api.dart';
112112
113113
var api_instance = new UserApi();
114-
var user = [new List&lt;User&gt;()]; // List<User> | List of user object
114+
var body = [new List&lt;User&gt;()]; // List<User> | List of user object
115115
116116
try {
117-
api_instance.createUsersWithListInput(user);
117+
api_instance.createUsersWithListInput(body);
118118
} catch (e) {
119119
print("Exception when calling UserApi->createUsersWithListInput: $e\n");
120120
}
@@ -124,7 +124,7 @@ try {
124124

125125
Name | Type | Description | Notes
126126
------------- | ------------- | ------------- | -------------
127-
**user** | [**List&lt;User&gt;**](List.md)| List of user object |
127+
**body** | [**List&lt;User&gt;**](List.md)| List of user object |
128128

129129
### Return type
130130

@@ -304,7 +304,7 @@ No authorization required
304304
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
305305

306306
# **updateUser**
307-
> updateUser(username, user)
307+
> updateUser(username, body)
308308
309309
Updated user
310310

@@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
316316
317317
var api_instance = new UserApi();
318318
var username = username_example; // String | name that need to be deleted
319-
var user = new User(); // User | Updated user object
319+
var body = new User(); // User | Updated user object
320320
321321
try {
322-
api_instance.updateUser(username, user);
322+
api_instance.updateUser(username, body);
323323
} catch (e) {
324324
print("Exception when calling UserApi->updateUser: $e\n");
325325
}
@@ -330,7 +330,7 @@ try {
330330
Name | Type | Description | Notes
331331
------------- | ------------- | ------------- | -------------
332332
**username** | **String**| name that need to be deleted | [default to null]
333-
**user** | [**User**](User.md)| Updated user object |
333+
**body** | [**User**](User.md)| Updated user object |
334334

335335
### Return type
336336

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api/pet_api.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class PetApi extends _$PetApiClient implements ApiClient {
2424
@PostReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
2525
Future<void> addPet(
2626

27-
@AsJson() Pet pet
27+
@AsJson() Pet body
2828
) {
2929
return super.addPet(
3030

3131

32-
pet
32+
body
3333
).timeout(timeout);
3434
}
3535

@@ -99,12 +99,12 @@ class PetApi extends _$PetApiClient implements ApiClient {
9999
@PutReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
100100
Future<void> updatePet(
101101

102-
@AsJson() Pet pet
102+
@AsJson() Pet body
103103
) {
104104
return super.updatePet(
105105

106106

107-
pet
107+
body
108108
).timeout(timeout);
109109
}
110110

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api/store_api.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
6060
@PostReq(path: "/store/order")
6161
Future<Order> placeOrder(
6262

63-
@AsJson() Order order
63+
@AsJson() Order body
6464
) {
6565
return super.placeOrder(
6666

6767

68-
order
68+
body
6969
).timeout(timeout);
7070
}
7171

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api/user_api.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
2323
@PostReq(path: "/user")
2424
Future<void> createUser(
2525

26-
@AsJson() User user
26+
@AsJson() User body
2727
) {
2828
return super.createUser(
2929

3030

31-
user
31+
body
3232
).timeout(timeout);
3333
}
3434

@@ -38,12 +38,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
3838
@PostReq(path: "/user/createWithArray")
3939
Future<void> createUsersWithArrayInput(
4040

41-
@AsJson() List<User> user
41+
@AsJson() List<User> body
4242
) {
4343
return super.createUsersWithArrayInput(
4444

4545

46-
user
46+
body
4747
).timeout(timeout);
4848
}
4949

@@ -53,12 +53,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
5353
@PostReq(path: "/user/createWithList")
5454
Future<void> createUsersWithListInput(
5555

56-
@AsJson() List<User> user
56+
@AsJson() List<User> body
5757
) {
5858
return super.createUsersWithListInput(
5959

6060

61-
user
61+
body
6262
).timeout(timeout);
6363
}
6464

@@ -125,13 +125,13 @@ class UserApi extends _$UserApiClient implements ApiClient {
125125
Future<void> updateUser(
126126
@PathParam("username") String username
127127
,
128-
@AsJson() User user
128+
@AsJson() User body
129129
) {
130130
return super.updateUser(
131131
username
132132

133133
,
134-
user
134+
body
135135
).timeout(timeout);
136136
}
137137

0 commit comments

Comments
 (0)