From 9ae0f512e2dcba3f1cde5ea44cec2639f01d45ef Mon Sep 17 00:00:00 2001 From: Yimin Lin Date: Tue, 28 Aug 2018 17:35:26 +0800 Subject: [PATCH] Run bin/dart2-petstore.sh to regenerate libraries --- .../flutter_petstore/openapi/lib/api.dart | 2 +- .../openapi/lib/api/pet_api.dart | 12 +++--- .../openapi/lib/api/store_api.dart | 6 +-- .../openapi/lib/api/user_api.dart | 8 ++-- .../openapi/lib/api_client.dart | 40 +++++++++---------- .../openapi/lib/api_exception.dart | 8 ++-- .../openapi/lib/api_helper.dart | 6 +-- .../openapi/lib/auth/api_key_auth.dart | 2 +- .../openapi/lib/auth/http_basic_auth.dart | 4 +- .../openapi/lib/auth/oauth.dart | 3 +- .../openapi/lib/model/pet.dart | 2 +- .../flutter_petstore/openapi/pubspec.yaml | 2 - .../dart2/openapi-browser-client/lib/api.dart | 2 +- .../lib/api/pet_api.dart | 12 +++--- .../lib/api/store_api.dart | 6 +-- .../lib/api/user_api.dart | 8 ++-- .../lib/api_client.dart | 40 +++++++++---------- .../lib/api_exception.dart | 8 ++-- .../lib/api_helper.dart | 6 +-- .../lib/auth/api_key_auth.dart | 2 +- .../lib/auth/http_basic_auth.dart | 4 +- .../lib/auth/oauth.dart | 3 +- .../openapi-browser-client/lib/model/pet.dart | 2 +- .../dart2/openapi-browser-client/pubspec.yaml | 2 - .../petstore/dart2/openapi/lib/api.dart | 2 +- .../dart2/openapi/lib/api/pet_api.dart | 12 +++--- .../dart2/openapi/lib/api/store_api.dart | 6 +-- .../dart2/openapi/lib/api/user_api.dart | 8 ++-- .../dart2/openapi/lib/api_client.dart | 36 ++++++++--------- .../dart2/openapi/lib/api_exception.dart | 8 ++-- .../dart2/openapi/lib/api_helper.dart | 6 +-- .../dart2/openapi/lib/auth/api_key_auth.dart | 2 +- .../dart2/openapi/lib/auth/oauth.dart | 3 +- .../petstore/dart2/openapi/lib/model/pet.dart | 2 +- .../petstore/dart2/openapi/pubspec.yaml | 2 - 35 files changed, 134 insertions(+), 143 deletions(-) diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart index 9a64a5342b4a..69c3ecd2e15d 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart @@ -24,4 +24,4 @@ part 'model/tag.dart'; part 'model/user.dart'; -ApiClient defaultApiClient = new ApiClient(); +ApiClient defaultApiClient = ApiClient(); diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart index 4134e018386d..8e6c815ec2b9 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart @@ -60,7 +60,7 @@ class PetApi { /// /// Future deletePet(int petId, { String apiKey }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -110,7 +110,7 @@ class PetApi { /// /// Multiple status values can be provided with comma separated strings Future> findPetsByStatus(List status) async { - Object postBody = null; + Object postBody; // verify required params are set if(status == null) { @@ -161,7 +161,7 @@ class PetApi { /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. Future> findPetsByTags(List tags) async { - Object postBody = null; + Object postBody; // verify required params are set if(tags == null) { @@ -212,7 +212,7 @@ class PetApi { /// /// Returns a single pet Future getPetById(int petId) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -311,7 +311,7 @@ class PetApi { /// /// Future updatePetWithForm(int petId, { String name, String status }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -372,7 +372,7 @@ class PetApi { /// /// Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart index f2a48f2d4dae..38fe10d44500 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart @@ -11,7 +11,7 @@ class StoreApi { /// /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors Future deleteOrder(String orderId) async { - Object postBody = null; + Object postBody; // verify required params are set if(orderId == null) { @@ -60,7 +60,7 @@ class StoreApi { /// /// Returns a map of status codes to quantities Future> getInventory() async { - Object postBody = null; + Object postBody; // verify required params are set @@ -108,7 +108,7 @@ class StoreApi { /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions Future getOrderById(int orderId) async { - Object postBody = null; + Object postBody; // verify required params are set if(orderId == null) { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart index cf8ef6bf8002..9d3eb116e615 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart @@ -158,7 +158,7 @@ class UserApi { /// /// This can only be done by the logged in user. Future deleteUser(String username) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -207,7 +207,7 @@ class UserApi { /// /// Future getUserByName(String username) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -257,7 +257,7 @@ class UserApi { /// /// Future loginUser(String username, String password) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -312,7 +312,7 @@ class UserApi { /// /// Future logoutUser() async { - Object postBody = null; + Object postBody; // verify required params are set diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart index db4116dd96dc..f1e49792f908 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart @@ -10,18 +10,18 @@ class QueryParam { class ApiClient { String basePath; - var client = new Client(); + var client = Client(); Map _defaultHeaderMap = {}; Map _authentications = {}; - final _RegList = new RegExp(r'^List<(.*)>$'); - final _RegMap = new RegExp(r'^Map$'); + final _regList = RegExp(r'^List<(.*)>$'); + final _regMap = RegExp(r'^Map$'); ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) { // Setup authentications (key: authentication name, value: authentication). - _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); - _authentications['petstore_auth'] = new OAuth(); + _authentications['api_key'] = ApiKeyAuth("header", "api_key"); + _authentications['petstore_auth'] = OAuth(); } void addDefaultHeader(String key, String value) { @@ -40,36 +40,36 @@ class ApiClient { case 'double': return value is double ? value : double.parse('$value'); case 'ApiResponse': - return new ApiResponse.fromJson(value); + return ApiResponse.fromJson(value); case 'Category': - return new Category.fromJson(value); + return Category.fromJson(value); case 'Order': - return new Order.fromJson(value); + return Order.fromJson(value); case 'Pet': - return new Pet.fromJson(value); + return Pet.fromJson(value); case 'Tag': - return new Tag.fromJson(value); + return Tag.fromJson(value); case 'User': - return new User.fromJson(value); + return User.fromJson(value); default: { Match match; if (value is List && - (match = _RegList.firstMatch(targetType)) != null) { + (match = _regList.firstMatch(targetType)) != null) { var newTargetType = match[1]; return value.map((v) => _deserialize(v, newTargetType)).toList(); } else if (value is Map && - (match = _RegMap.firstMatch(targetType)) != null) { + (match = _regMap.firstMatch(targetType)) != null) { var newTargetType = match[1]; - return new Map.fromIterables(value.keys, + return Map.fromIterables(value.keys, value.values.map((v) => _deserialize(v, newTargetType))); } } } } catch (e, stack) { - throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); + throw ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw new ApiException(500, 'Could not find a suitable class for deserialization'); + throw ApiException(500, 'Could not find a suitable class for deserialization'); } dynamic deserialize(String json, String targetType) { @@ -78,7 +78,7 @@ class ApiClient { if (targetType == 'String') return json; - var decodedJson = JSON.decode(json); + var decodedJson = jsonDecode(json); return _deserialize(decodedJson, targetType); } @@ -87,7 +87,7 @@ class ApiClient { if (obj == null) { serialized = ''; } else { - serialized = JSON.encode(obj); + serialized = json.encode(obj); } return serialized; } @@ -116,7 +116,7 @@ class ApiClient { headerParams['Content-Type'] = contentType; if(body is MultipartRequest) { - var request = new MultipartRequest(method, Uri.parse(url)); + var request = MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); request.headers.addAll(body.headers); @@ -145,7 +145,7 @@ class ApiClient { void _updateParamsForAuth(List authNames, List queryParams, Map headerParams) { authNames.forEach((authName) { Authentication auth = _authentications[authName]; - if (auth == null) throw new ArgumentError("Authentication undefined: " + authName); + if (auth == null) throw ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart index f188fd125a4d..668abe2c96bc 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart @@ -2,9 +2,9 @@ part of openapi.api; class ApiException implements Exception { int code = 0; - String message = null; - Exception innerException = null; - StackTrace stackTrace = null; + String message; + Exception innerException; + StackTrace stackTrace; ApiException(this.code, this.message); @@ -17,7 +17,7 @@ class ApiException implements Exception { return "ApiException $code: $message"; } - return "ApiException $code: $message (Inner exception: ${innerException})\n\n" + + return "ApiException $code: $message (Inner exception: $innerException)\n\n" + stackTrace.toString(); } } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart index 79af4521d5b3..a516a68d2649 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart @@ -11,7 +11,7 @@ Iterable _convertParametersForCollectionFormat( if (name == null || name.isEmpty || value == null) return params; if (value is! List) { - params.add(new QueryParam(name, parameterToString(value))); + params.add(QueryParam(name, parameterToString(value))); return params; } @@ -23,12 +23,12 @@ Iterable _convertParametersForCollectionFormat( : collectionFormat; // default: csv if (collectionFormat == "multi") { - return values.map((v) => new QueryParam(name, parameterToString(v))); + return values.map((v) => QueryParam(name, parameterToString(v))); } String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart index f9617f7ae4da..8caf6ab5ebae 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart @@ -19,7 +19,7 @@ class ApiKeyAuth implements Authentication { } if (location == 'query' && value != null) { - queryParams.add(new QueryParam(paramName, value)); + queryParams.add(QueryParam(paramName, value)); } else if (location == 'header' && value != null) { headerParams[paramName] = value; } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart index 4e77ddcf6e68..6342d8866892 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart @@ -8,7 +8,7 @@ class HttpBasicAuth implements Authentication { @override void applyToParams(List queryParams, Map headerParams) { String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str)); + headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str)); } -} \ No newline at end of file +} diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart index 13bfd799743b..aa08e5cdb4d1 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart @@ -3,8 +3,7 @@ part of openapi.api; class OAuth implements Authentication { String accessToken; - OAuth({this.accessToken}) { - } + OAuth({this.accessToken}); @override void applyToParams(List queryParams, Map headerParams) { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart index 4d2f77a1a5ae..da9de49b6787 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart @@ -26,7 +26,7 @@ class Pet { id = json['id']; category = new Category.fromJson(json['category']); name = json['name']; - photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); + photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList(); tags = Tag.listFromJson(json['tags']); status = json['status']; } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/pubspec.yaml b/samples/client/petstore/dart2/flutter_petstore/openapi/pubspec.yaml index 9ccf0e524ad0..d54efb46a2e4 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/pubspec.yaml +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/pubspec.yaml @@ -1,7 +1,5 @@ name: openapi version: 1.0.0 description: OpenAPI API client -environment: - sdk: '>=2.0.0 <3.0.0' dependencies: http: '>=0.11.1 <0.12.0' diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart index 84476e0626af..4e43a1c2083f 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart @@ -25,4 +25,4 @@ part 'model/tag.dart'; part 'model/user.dart'; -ApiClient defaultApiClient = new ApiClient(); +ApiClient defaultApiClient = ApiClient(); diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart index 4134e018386d..8e6c815ec2b9 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart @@ -60,7 +60,7 @@ class PetApi { /// /// Future deletePet(int petId, { String apiKey }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -110,7 +110,7 @@ class PetApi { /// /// Multiple status values can be provided with comma separated strings Future> findPetsByStatus(List status) async { - Object postBody = null; + Object postBody; // verify required params are set if(status == null) { @@ -161,7 +161,7 @@ class PetApi { /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. Future> findPetsByTags(List tags) async { - Object postBody = null; + Object postBody; // verify required params are set if(tags == null) { @@ -212,7 +212,7 @@ class PetApi { /// /// Returns a single pet Future getPetById(int petId) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -311,7 +311,7 @@ class PetApi { /// /// Future updatePetWithForm(int petId, { String name, String status }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -372,7 +372,7 @@ class PetApi { /// /// Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart index f2a48f2d4dae..38fe10d44500 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart @@ -11,7 +11,7 @@ class StoreApi { /// /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors Future deleteOrder(String orderId) async { - Object postBody = null; + Object postBody; // verify required params are set if(orderId == null) { @@ -60,7 +60,7 @@ class StoreApi { /// /// Returns a map of status codes to quantities Future> getInventory() async { - Object postBody = null; + Object postBody; // verify required params are set @@ -108,7 +108,7 @@ class StoreApi { /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions Future getOrderById(int orderId) async { - Object postBody = null; + Object postBody; // verify required params are set if(orderId == null) { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart index cf8ef6bf8002..9d3eb116e615 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart @@ -158,7 +158,7 @@ class UserApi { /// /// This can only be done by the logged in user. Future deleteUser(String username) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -207,7 +207,7 @@ class UserApi { /// /// Future getUserByName(String username) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -257,7 +257,7 @@ class UserApi { /// /// Future loginUser(String username, String password) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -312,7 +312,7 @@ class UserApi { /// /// Future logoutUser() async { - Object postBody = null; + Object postBody; // verify required params are set diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart index 7cca5bef5f26..2ffa4e695a53 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart @@ -10,18 +10,18 @@ class QueryParam { class ApiClient { String basePath; - var client = new BrowserClient(); + var client = BrowserClient(); Map _defaultHeaderMap = {}; Map _authentications = {}; - final _RegList = new RegExp(r'^List<(.*)>$'); - final _RegMap = new RegExp(r'^Map$'); + final _regList = RegExp(r'^List<(.*)>$'); + final _regMap = RegExp(r'^Map$'); ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) { // Setup authentications (key: authentication name, value: authentication). - _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); - _authentications['petstore_auth'] = new OAuth(); + _authentications['api_key'] = ApiKeyAuth("header", "api_key"); + _authentications['petstore_auth'] = OAuth(); } void addDefaultHeader(String key, String value) { @@ -40,36 +40,36 @@ class ApiClient { case 'double': return value is double ? value : double.parse('$value'); case 'ApiResponse': - return new ApiResponse.fromJson(value); + return ApiResponse.fromJson(value); case 'Category': - return new Category.fromJson(value); + return Category.fromJson(value); case 'Order': - return new Order.fromJson(value); + return Order.fromJson(value); case 'Pet': - return new Pet.fromJson(value); + return Pet.fromJson(value); case 'Tag': - return new Tag.fromJson(value); + return Tag.fromJson(value); case 'User': - return new User.fromJson(value); + return User.fromJson(value); default: { Match match; if (value is List && - (match = _RegList.firstMatch(targetType)) != null) { + (match = _regList.firstMatch(targetType)) != null) { var newTargetType = match[1]; return value.map((v) => _deserialize(v, newTargetType)).toList(); } else if (value is Map && - (match = _RegMap.firstMatch(targetType)) != null) { + (match = _regMap.firstMatch(targetType)) != null) { var newTargetType = match[1]; - return new Map.fromIterables(value.keys, + return Map.fromIterables(value.keys, value.values.map((v) => _deserialize(v, newTargetType))); } } } } catch (e, stack) { - throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); + throw ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw new ApiException(500, 'Could not find a suitable class for deserialization'); + throw ApiException(500, 'Could not find a suitable class for deserialization'); } dynamic deserialize(String json, String targetType) { @@ -78,7 +78,7 @@ class ApiClient { if (targetType == 'String') return json; - var decodedJson = JSON.decode(json); + var decodedJson = jsonDecode(json); return _deserialize(decodedJson, targetType); } @@ -87,7 +87,7 @@ class ApiClient { if (obj == null) { serialized = ''; } else { - serialized = JSON.encode(obj); + serialized = json.encode(obj); } return serialized; } @@ -116,7 +116,7 @@ class ApiClient { headerParams['Content-Type'] = contentType; if(body is MultipartRequest) { - var request = new MultipartRequest(method, Uri.parse(url)); + var request = MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); request.headers.addAll(body.headers); @@ -145,7 +145,7 @@ class ApiClient { void _updateParamsForAuth(List authNames, List queryParams, Map headerParams) { authNames.forEach((authName) { Authentication auth = _authentications[authName]; - if (auth == null) throw new ArgumentError("Authentication undefined: " + authName); + if (auth == null) throw ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart index f188fd125a4d..668abe2c96bc 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart @@ -2,9 +2,9 @@ part of openapi.api; class ApiException implements Exception { int code = 0; - String message = null; - Exception innerException = null; - StackTrace stackTrace = null; + String message; + Exception innerException; + StackTrace stackTrace; ApiException(this.code, this.message); @@ -17,7 +17,7 @@ class ApiException implements Exception { return "ApiException $code: $message"; } - return "ApiException $code: $message (Inner exception: ${innerException})\n\n" + + return "ApiException $code: $message (Inner exception: $innerException)\n\n" + stackTrace.toString(); } } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart index 79af4521d5b3..a516a68d2649 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart @@ -11,7 +11,7 @@ Iterable _convertParametersForCollectionFormat( if (name == null || name.isEmpty || value == null) return params; if (value is! List) { - params.add(new QueryParam(name, parameterToString(value))); + params.add(QueryParam(name, parameterToString(value))); return params; } @@ -23,12 +23,12 @@ Iterable _convertParametersForCollectionFormat( : collectionFormat; // default: csv if (collectionFormat == "multi") { - return values.map((v) => new QueryParam(name, parameterToString(v))); + return values.map((v) => QueryParam(name, parameterToString(v))); } String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart index f9617f7ae4da..8caf6ab5ebae 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart @@ -19,7 +19,7 @@ class ApiKeyAuth implements Authentication { } if (location == 'query' && value != null) { - queryParams.add(new QueryParam(paramName, value)); + queryParams.add(QueryParam(paramName, value)); } else if (location == 'header' && value != null) { headerParams[paramName] = value; } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart index 4e77ddcf6e68..6342d8866892 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart @@ -8,7 +8,7 @@ class HttpBasicAuth implements Authentication { @override void applyToParams(List queryParams, Map headerParams) { String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str)); + headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str)); } -} \ No newline at end of file +} diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart index 13bfd799743b..aa08e5cdb4d1 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart @@ -3,8 +3,7 @@ part of openapi.api; class OAuth implements Authentication { String accessToken; - OAuth({this.accessToken}) { - } + OAuth({this.accessToken}); @override void applyToParams(List queryParams, Map headerParams) { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart index 4d2f77a1a5ae..da9de49b6787 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart @@ -26,7 +26,7 @@ class Pet { id = json['id']; category = new Category.fromJson(json['category']); name = json['name']; - photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); + photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList(); tags = Tag.listFromJson(json['tags']); status = json['status']; } diff --git a/samples/client/petstore/dart2/openapi-browser-client/pubspec.yaml b/samples/client/petstore/dart2/openapi-browser-client/pubspec.yaml index 9ccf0e524ad0..d54efb46a2e4 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/pubspec.yaml +++ b/samples/client/petstore/dart2/openapi-browser-client/pubspec.yaml @@ -1,7 +1,5 @@ name: openapi version: 1.0.0 description: OpenAPI API client -environment: - sdk: '>=2.0.0 <3.0.0' dependencies: http: '>=0.11.1 <0.12.0' diff --git a/samples/client/petstore/dart2/openapi/lib/api.dart b/samples/client/petstore/dart2/openapi/lib/api.dart index 9a64a5342b4a..69c3ecd2e15d 100644 --- a/samples/client/petstore/dart2/openapi/lib/api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api.dart @@ -24,4 +24,4 @@ part 'model/tag.dart'; part 'model/user.dart'; -ApiClient defaultApiClient = new ApiClient(); +ApiClient defaultApiClient = ApiClient(); diff --git a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart index 4134e018386d..8e6c815ec2b9 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart @@ -60,7 +60,7 @@ class PetApi { /// /// Future deletePet(int petId, { String apiKey }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -110,7 +110,7 @@ class PetApi { /// /// Multiple status values can be provided with comma separated strings Future> findPetsByStatus(List status) async { - Object postBody = null; + Object postBody; // verify required params are set if(status == null) { @@ -161,7 +161,7 @@ class PetApi { /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. Future> findPetsByTags(List tags) async { - Object postBody = null; + Object postBody; // verify required params are set if(tags == null) { @@ -212,7 +212,7 @@ class PetApi { /// /// Returns a single pet Future getPetById(int petId) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -311,7 +311,7 @@ class PetApi { /// /// Future updatePetWithForm(int petId, { String name, String status }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { @@ -372,7 +372,7 @@ class PetApi { /// /// Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { - Object postBody = null; + Object postBody; // verify required params are set if(petId == null) { diff --git a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart index f2a48f2d4dae..38fe10d44500 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart @@ -11,7 +11,7 @@ class StoreApi { /// /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors Future deleteOrder(String orderId) async { - Object postBody = null; + Object postBody; // verify required params are set if(orderId == null) { @@ -60,7 +60,7 @@ class StoreApi { /// /// Returns a map of status codes to quantities Future> getInventory() async { - Object postBody = null; + Object postBody; // verify required params are set @@ -108,7 +108,7 @@ class StoreApi { /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions Future getOrderById(int orderId) async { - Object postBody = null; + Object postBody; // verify required params are set if(orderId == null) { diff --git a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart index cf8ef6bf8002..9d3eb116e615 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart @@ -158,7 +158,7 @@ class UserApi { /// /// This can only be done by the logged in user. Future deleteUser(String username) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -207,7 +207,7 @@ class UserApi { /// /// Future getUserByName(String username) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -257,7 +257,7 @@ class UserApi { /// /// Future loginUser(String username, String password) async { - Object postBody = null; + Object postBody; // verify required params are set if(username == null) { @@ -312,7 +312,7 @@ class UserApi { /// /// Future logoutUser() async { - Object postBody = null; + Object postBody; // verify required params are set diff --git a/samples/client/petstore/dart2/openapi/lib/api_client.dart b/samples/client/petstore/dart2/openapi/lib/api_client.dart index 042deb946aeb..f1e49792f908 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_client.dart @@ -10,18 +10,18 @@ class QueryParam { class ApiClient { String basePath; - var client = new Client(); + var client = Client(); Map _defaultHeaderMap = {}; Map _authentications = {}; - final _RegList = new RegExp(r'^List<(.*)>$'); - final _RegMap = new RegExp(r'^Map$'); + final _regList = RegExp(r'^List<(.*)>$'); + final _regMap = RegExp(r'^Map$'); ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) { // Setup authentications (key: authentication name, value: authentication). - _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); - _authentications['petstore_auth'] = new OAuth(); + _authentications['api_key'] = ApiKeyAuth("header", "api_key"); + _authentications['petstore_auth'] = OAuth(); } void addDefaultHeader(String key, String value) { @@ -40,36 +40,36 @@ class ApiClient { case 'double': return value is double ? value : double.parse('$value'); case 'ApiResponse': - return new ApiResponse.fromJson(value); + return ApiResponse.fromJson(value); case 'Category': - return new Category.fromJson(value); + return Category.fromJson(value); case 'Order': - return new Order.fromJson(value); + return Order.fromJson(value); case 'Pet': - return new Pet.fromJson(value); + return Pet.fromJson(value); case 'Tag': - return new Tag.fromJson(value); + return Tag.fromJson(value); case 'User': - return new User.fromJson(value); + return User.fromJson(value); default: { Match match; if (value is List && - (match = _RegList.firstMatch(targetType)) != null) { + (match = _regList.firstMatch(targetType)) != null) { var newTargetType = match[1]; return value.map((v) => _deserialize(v, newTargetType)).toList(); } else if (value is Map && - (match = _RegMap.firstMatch(targetType)) != null) { + (match = _regMap.firstMatch(targetType)) != null) { var newTargetType = match[1]; - return new Map.fromIterables(value.keys, + return Map.fromIterables(value.keys, value.values.map((v) => _deserialize(v, newTargetType))); } } } } catch (e, stack) { - throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); + throw ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw new ApiException(500, 'Could not find a suitable class for deserialization'); + throw ApiException(500, 'Could not find a suitable class for deserialization'); } dynamic deserialize(String json, String targetType) { @@ -116,7 +116,7 @@ class ApiClient { headerParams['Content-Type'] = contentType; if(body is MultipartRequest) { - var request = new MultipartRequest(method, Uri.parse(url)); + var request = MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); request.headers.addAll(body.headers); @@ -145,7 +145,7 @@ class ApiClient { void _updateParamsForAuth(List authNames, List queryParams, Map headerParams) { authNames.forEach((authName) { Authentication auth = _authentications[authName]; - if (auth == null) throw new ArgumentError("Authentication undefined: " + authName); + if (auth == null) throw ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart2/openapi/lib/api_exception.dart b/samples/client/petstore/dart2/openapi/lib/api_exception.dart index f188fd125a4d..668abe2c96bc 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_exception.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_exception.dart @@ -2,9 +2,9 @@ part of openapi.api; class ApiException implements Exception { int code = 0; - String message = null; - Exception innerException = null; - StackTrace stackTrace = null; + String message; + Exception innerException; + StackTrace stackTrace; ApiException(this.code, this.message); @@ -17,7 +17,7 @@ class ApiException implements Exception { return "ApiException $code: $message"; } - return "ApiException $code: $message (Inner exception: ${innerException})\n\n" + + return "ApiException $code: $message (Inner exception: $innerException)\n\n" + stackTrace.toString(); } } diff --git a/samples/client/petstore/dart2/openapi/lib/api_helper.dart b/samples/client/petstore/dart2/openapi/lib/api_helper.dart index 79af4521d5b3..a516a68d2649 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_helper.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_helper.dart @@ -11,7 +11,7 @@ Iterable _convertParametersForCollectionFormat( if (name == null || name.isEmpty || value == null) return params; if (value is! List) { - params.add(new QueryParam(name, parameterToString(value))); + params.add(QueryParam(name, parameterToString(value))); return params; } @@ -23,12 +23,12 @@ Iterable _convertParametersForCollectionFormat( : collectionFormat; // default: csv if (collectionFormat == "multi") { - return values.map((v) => new QueryParam(name, parameterToString(v))); + return values.map((v) => QueryParam(name, parameterToString(v))); } String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart b/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart index f9617f7ae4da..8caf6ab5ebae 100644 --- a/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart @@ -19,7 +19,7 @@ class ApiKeyAuth implements Authentication { } if (location == 'query' && value != null) { - queryParams.add(new QueryParam(paramName, value)); + queryParams.add(QueryParam(paramName, value)); } else if (location == 'header' && value != null) { headerParams[paramName] = value; } diff --git a/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart b/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart index 13bfd799743b..aa08e5cdb4d1 100644 --- a/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart +++ b/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart @@ -3,8 +3,7 @@ part of openapi.api; class OAuth implements Authentication { String accessToken; - OAuth({this.accessToken}) { - } + OAuth({this.accessToken}); @override void applyToParams(List queryParams, Map headerParams) { diff --git a/samples/client/petstore/dart2/openapi/lib/model/pet.dart b/samples/client/petstore/dart2/openapi/lib/model/pet.dart index 4d2f77a1a5ae..da9de49b6787 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/pet.dart @@ -26,7 +26,7 @@ class Pet { id = json['id']; category = new Category.fromJson(json['category']); name = json['name']; - photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); + photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList(); tags = Tag.listFromJson(json['tags']); status = json['status']; } diff --git a/samples/client/petstore/dart2/openapi/pubspec.yaml b/samples/client/petstore/dart2/openapi/pubspec.yaml index 9ccf0e524ad0..d54efb46a2e4 100644 --- a/samples/client/petstore/dart2/openapi/pubspec.yaml +++ b/samples/client/petstore/dart2/openapi/pubspec.yaml @@ -1,7 +1,5 @@ name: openapi version: 1.0.0 description: OpenAPI API client -environment: - sdk: '>=2.0.0 <3.0.0' dependencies: http: '>=0.11.1 <0.12.0'