Skip to content

Commit 5daeacd

Browse files
committed
dart: run bin/dart-petstore.sh
1 parent 8cd30cf commit 5daeacd

File tree

24 files changed

+369
-19
lines changed

24 files changed

+369
-19
lines changed

samples/client/petstore/dart/flutter_petstore/swagger/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ Class | Method | HTTP request | Description
8787

8888
## Documentation For Models
8989

90+
- [Amount](docs//Amount.md)
9091
- [ApiResponse](docs//ApiResponse.md)
9192
- [Category](docs//Category.md)
93+
- [Currency](docs//Currency.md)
9294
- [Order](docs//Order.md)
9395
- [Pet](docs//Pet.md)
9496
- [Tag](docs//Tag.md)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# swagger.model.Amount
2+
3+
## Load the model package
4+
```dart
5+
import 'package:swagger/api.dart';
6+
```
7+
8+
## Properties
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**value** | **double** | some description | [default to null]
12+
**currency** | [**Currency**](Currency.md) | | [default to null]
13+
14+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
15+
16+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# swagger.model.Currency
2+
3+
## Load the model package
4+
```dart
5+
import 'package:swagger/api.dart';
6+
```
7+
8+
## Properties
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
12+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
13+
14+

samples/client/petstore/dart/flutter_petstore/swagger/lib/api.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library swagger.api;
22

3-
import 'dart:convert';
43
import 'dart:async';
4+
import 'dart:convert';
55
import 'package:http/http.dart';
66

77
part 'api_client.dart';
@@ -16,8 +16,10 @@ part 'api/pet_api.dart';
1616
part 'api/store_api.dart';
1717
part 'api/user_api.dart';
1818

19+
part 'model/amount.dart';
1920
part 'model/api_response.dart';
2021
part 'model/category.dart';
22+
part 'model/currency.dart';
2123
part 'model/order.dart';
2224
part 'model/pet.dart';
2325
part 'model/tag.dart';

samples/client/petstore/dart/flutter_petstore/swagger/lib/api_client.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ class ApiClient {
3939
return value is bool ? value : '$value'.toLowerCase() == 'true';
4040
case 'double':
4141
return value is double ? value : double.parse('$value');
42+
case 'Amount':
43+
return new Amount.fromJson(value);
4244
case 'ApiResponse':
4345
return new ApiResponse.fromJson(value);
4446
case 'Category':
4547
return new Category.fromJson(value);
48+
case 'Currency':
49+
return new Currency.fromJson(value);
4650
case 'Order':
4751
return new Order.fromJson(value);
4852
case 'Pet':
@@ -72,13 +76,13 @@ class ApiClient {
7276
throw new ApiException(500, 'Could not find a suitable class for deserialization');
7377
}
7478

75-
dynamic deserialize(String jsonStr, String targetType) {
79+
dynamic deserialize(String jsonVal, String targetType) {
7680
// Remove all spaces. Necessary for reg expressions as well.
7781
targetType = targetType.replaceAll(' ', '');
7882

79-
if (targetType == 'String') return jsonStr;
83+
if (targetType == 'String') return jsonVal;
8084

81-
var decodedJson = json.decode(jsonStr);
85+
var decodedJson = json.decode(jsonVal);
8286
return _deserialize(decodedJson, targetType);
8387
}
8488

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
part of swagger.api;
2+
3+
class Amount {
4+
/* some description */
5+
double value = null;
6+
// range from 0.01 to 1000000000000000//
7+
8+
Currency currency = null;
9+
10+
Amount();
11+
12+
@override
13+
String toString() {
14+
return 'Amount[value=$value, currency=$currency, ]';
15+
}
16+
17+
Amount.fromJson(Map<String, dynamic> json) {
18+
if (json == null) return;
19+
value =
20+
json['value']
21+
;
22+
currency =
23+
24+
25+
new Currency.fromJson(json['currency'])
26+
;
27+
}
28+
29+
Map<String, dynamic> toJson() {
30+
return {
31+
'value': value,
32+
'currency': currency
33+
};
34+
}
35+
36+
static List<Amount> listFromJson(List<dynamic> json) {
37+
return json == null ? new List<Amount>() : json.map((value) => new Amount.fromJson(value)).toList();
38+
}
39+
40+
static Map<String, Amount> mapFromJson(Map<String, Map<String, dynamic>> json) {
41+
var map = new Map<String, Amount>();
42+
if (json != null && json.length > 0) {
43+
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Amount.fromJson(value));
44+
}
45+
return map;
46+
}
47+
}
48+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
part of swagger.api;
2+
3+
class Currency {
4+
Currency();
5+
6+
@override
7+
String toString() {
8+
return 'Currency[]';
9+
}
10+
11+
Currency.fromJson(Map<String, dynamic> json) {
12+
if (json == null) return;
13+
}
14+
15+
Map<String, dynamic> toJson() {
16+
return {
17+
};
18+
}
19+
20+
static List<Currency> listFromJson(List<dynamic> json) {
21+
return json == null ? new List<Currency>() : json.map((value) => new Currency.fromJson(value)).toList();
22+
}
23+
24+
static Map<String, Currency> mapFromJson(Map<String, Map<String, dynamic>> json) {
25+
var map = new Map<String, Currency>();
26+
if (json != null && json.length > 0) {
27+
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Currency.fromJson(value));
28+
}
29+
return map;
30+
}
31+
}
32+
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: swagger
22
version: 1.0.0
33
description: Swagger API client
4-
5-
environment:
6-
sdk: ">=1.19.0 <3.0.0"
7-
84
dependencies:
9-
http:
5+
http: '>=0.11.1 <0.12.0'

samples/client/petstore/dart/swagger-browser-client/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ Class | Method | HTTP request | Description
8787

8888
## Documentation For Models
8989

90+
- [Amount](docs//Amount.md)
9091
- [ApiResponse](docs//ApiResponse.md)
9192
- [Category](docs//Category.md)
93+
- [Currency](docs//Currency.md)
9294
- [Order](docs//Order.md)
9395
- [Pet](docs//Pet.md)
9496
- [Tag](docs//Tag.md)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# swagger.model.Amount
2+
3+
## Load the model package
4+
```dart
5+
import 'package:swagger/api.dart';
6+
```
7+
8+
## Properties
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**value** | **double** | some description | [default to null]
12+
**currency** | [**Currency**](Currency.md) | | [default to null]
13+
14+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
15+
16+

0 commit comments

Comments
 (0)