diff --git a/modules/openapi-generator/src/main/resources/dart2/api.mustache b/modules/openapi-generator/src/main/resources/dart2/api.mustache index 219b85dc56a1..1c995009e018 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api.mustache @@ -50,7 +50,7 @@ class {{{classname}}} { /// {{/-last}} {{/allParams}} - Future {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async { + Future {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}, {{/required}}{{/allParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}}, {{/required}}{{/allParams}}Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'{{{path}}}'{{#pathParams}} .replaceAll({{=<% %>=}}'{<% baseName %>}'<%={{ }}=%>, {{{paramName}}}{{^isString}}.toString(){{/isString}}){{/pathParams}}; @@ -129,6 +129,7 @@ class {{{classname}}} { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -162,8 +163,8 @@ class {{{classname}}} { /// {{/-last}} {{/allParams}} - Future<{{#returnType}}{{{.}}}?{{/returnType}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async { - final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}}); + Future<{{#returnType}}{{{.}}}?{{/returnType}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}, {{/required}}{{/allParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}}, {{/required}}{{/allParams}}Future? abortTrigger, }) async { + final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}}, {{/required}}{{/allParams}}{{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}}, {{/required}}{{/allParams}}abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache index 4185524e894d..f6967fdaba75 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache @@ -35,8 +35,9 @@ class ApiClient { Object? body, Map headerParams, Map formParams, - String? contentType, - ) async { + String? contentType, { + Future? abortTrigger, + }) async { await authentication?.applyToParams(queryParams, headerParams); headerParams.addAll(_defaultHeaderMap); @@ -54,7 +55,7 @@ class ApiClient { body is MultipartFile && (contentType == null || !contentType.toLowerCase().startsWith('multipart/form-data')) ) { - final request = StreamedRequest(method, uri); + final request = AbortableStreamedRequest(method, uri, abortTrigger: abortTrigger); request.headers.addAll(headerParams); request.contentLength = body.length; body.finalize().listen( @@ -69,7 +70,7 @@ class ApiClient { } if (body is MultipartRequest) { - final request = MultipartRequest(method, uri); + final request = AbortableMultipartRequest(method, uri, abortTrigger: abortTrigger); request.fields.addAll(body.fields); request.files.addAll(body.files); request.headers.addAll(body.headers); @@ -83,14 +84,19 @@ class ApiClient { : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; - switch(method) { - case 'POST': return await _client.post(uri, headers: nullableHeaderParams, body: msgBody,); - case 'PUT': return await _client.put(uri, headers: nullableHeaderParams, body: msgBody,); - case 'DELETE': return await _client.delete(uri, headers: nullableHeaderParams, body: msgBody,); - case 'PATCH': return await _client.patch(uri, headers: nullableHeaderParams, body: msgBody,); - case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,); - case 'GET': return await _client.get(uri, headers: nullableHeaderParams,); + final request = AbortableRequest(method, uri, abortTrigger: abortTrigger); + if (nullableHeaderParams != null) { + request.headers.addAll(nullableHeaderParams); } + if (msgBody is String && msgBody.isNotEmpty) { + request.body = msgBody; + } else if (msgBody is List && msgBody.isNotEmpty) { + request.bodyBytes = msgBody; + } else if (msgBody is Map) { + request.bodyFields = msgBody; + } + final response = await _client.send(request); + return Response.fromStream(response); } on SocketException catch (error, trace) { throw ApiException.withInner( HttpStatus.badRequest, @@ -127,11 +133,6 @@ class ApiClient { trace, ); } - - throw ApiException( - HttpStatus.badRequest, - 'Invalid HTTP operation: $method $path', - ); } {{#native_serialization}} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart index f6cb28f6cc2a..65bd7ec0d8d2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart @@ -26,7 +26,7 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPetWithHttpInfo(Pet pet,) async { + Future addPetWithHttpInfo(Pet pet, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet'; @@ -48,6 +48,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -59,8 +60,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPet(Pet pet,) async { - final response = await addPetWithHttpInfo(pet,); + Future addPet(Pet pet, { Future? abortTrigger, }) async { + final response = await addPetWithHttpInfo(pet, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -86,7 +87,7 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePetWithHttpInfo(int petId, { String? apiKey, }) async { + Future deletePetWithHttpInfo(int petId, { String? apiKey, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}' .replaceAll('{petId}', petId.toString()); @@ -113,6 +114,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -126,8 +128,8 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePet(int petId, { String? apiKey, }) async { - final response = await deletePetWithHttpInfo(petId, apiKey: apiKey, ); + Future deletePet(int petId, { String? apiKey, Future? abortTrigger, }) async { + final response = await deletePetWithHttpInfo(petId, apiKey: apiKey, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -143,7 +145,7 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future findPetsByStatusWithHttpInfo(List status,) async { + Future findPetsByStatusWithHttpInfo(List status, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/findByStatus'; @@ -167,6 +169,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -178,8 +181,8 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future?> findPetsByStatus(List status,) async { - final response = await findPetsByStatusWithHttpInfo(status,); + Future?> findPetsByStatus(List status, { Future? abortTrigger, }) async { + final response = await findPetsByStatusWithHttpInfo(status, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -206,7 +209,7 @@ class PetApi { /// /// * [List] tags (required): /// Tags to filter by - Future findPetsByTagsWithHttpInfo(List tags,) async { + Future findPetsByTagsWithHttpInfo(List tags, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/findByTags'; @@ -230,6 +233,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -241,8 +245,8 @@ class PetApi { /// /// * [List] tags (required): /// Tags to filter by - Future?> findPetsByTags(List tags,) async { - final response = await findPetsByTagsWithHttpInfo(tags,); + Future?> findPetsByTags(List tags, { Future? abortTrigger, }) async { + final response = await findPetsByTagsWithHttpInfo(tags, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -269,7 +273,7 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetByIdWithHttpInfo(int petId,) async { + Future getPetByIdWithHttpInfo(int petId, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}' .replaceAll('{petId}', petId.toString()); @@ -292,6 +296,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -303,8 +308,8 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetById(int petId,) async { - final response = await getPetByIdWithHttpInfo(petId,); + Future getPetById(int petId, { Future? abortTrigger, }) async { + final response = await getPetByIdWithHttpInfo(petId, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -328,7 +333,7 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePetWithHttpInfo(Pet pet,) async { + Future updatePetWithHttpInfo(Pet pet, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet'; @@ -350,6 +355,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -361,8 +367,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePet(Pet pet,) async { - final response = await updatePetWithHttpInfo(pet,); + Future updatePet(Pet pet, { Future? abortTrigger, }) async { + final response = await updatePetWithHttpInfo(pet, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -392,7 +398,7 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithFormWithHttpInfo(int petId, { String? name, String? status, }) async { + Future updatePetWithFormWithHttpInfo(int petId, { String? name, String? status, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}' .replaceAll('{petId}', petId.toString()); @@ -421,6 +427,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -438,8 +445,8 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithForm(int petId, { String? name, String? status, }) async { - final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status, ); + Future updatePetWithForm(int petId, { String? name, String? status, Future? abortTrigger, }) async { + final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -461,7 +468,7 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFileWithHttpInfo(int petId, { String? additionalMetadata, MultipartFile? file, }) async { + Future uploadFileWithHttpInfo(int petId, { String? additionalMetadata, MultipartFile? file, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}/uploadImage' .replaceAll('{petId}', petId.toString()); @@ -498,6 +505,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -515,8 +523,8 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFile(int petId, { String? additionalMetadata, MultipartFile? file, }) async { - final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file, ); + Future uploadFile(int petId, { String? additionalMetadata, MultipartFile? file, Future? abortTrigger, }) async { + final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart index e27c2b04cb8b..d07ef5676ef9 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart @@ -26,7 +26,7 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrderWithHttpInfo(String orderId,) async { + Future deleteOrderWithHttpInfo(String orderId, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/order/{orderId}' .replaceAll('{orderId}', orderId); @@ -49,6 +49,7 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -60,8 +61,8 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrder(String orderId,) async { - final response = await deleteOrderWithHttpInfo(orderId,); + Future deleteOrder(String orderId, { Future? abortTrigger, }) async { + final response = await deleteOrderWithHttpInfo(orderId, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -72,7 +73,7 @@ class StoreApi { /// Returns a map of status codes to quantities /// /// Note: This method returns the HTTP [Response]. - Future getInventoryWithHttpInfo() async { + Future getInventoryWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/inventory'; @@ -94,14 +95,15 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } /// Returns pet inventories by status /// /// Returns a map of status codes to quantities - Future?> getInventory() async { - final response = await getInventoryWithHttpInfo(); + Future?> getInventory({ Future? abortTrigger, }) async { + final response = await getInventoryWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -125,7 +127,7 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderByIdWithHttpInfo(int orderId,) async { + Future getOrderByIdWithHttpInfo(int orderId, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/order/{orderId}' .replaceAll('{orderId}', orderId.toString()); @@ -148,6 +150,7 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -159,8 +162,8 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderById(int orderId,) async { - final response = await getOrderByIdWithHttpInfo(orderId,); + Future getOrderById(int orderId, { Future? abortTrigger, }) async { + final response = await getOrderByIdWithHttpInfo(orderId, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -184,7 +187,7 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrderWithHttpInfo(Order order,) async { + Future placeOrderWithHttpInfo(Order order, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/order'; @@ -206,6 +209,7 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -217,8 +221,8 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrder(Order order,) async { - final response = await placeOrderWithHttpInfo(order,); + Future placeOrder(Order order, { Future? abortTrigger, }) async { + final response = await placeOrderWithHttpInfo(order, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart index 4c59eb21f63e..e17392c958c2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart @@ -26,7 +26,7 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUserWithHttpInfo(User user,) async { + Future createUserWithHttpInfo(User user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user'; @@ -48,6 +48,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -59,8 +60,8 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUser(User user,) async { - final response = await createUserWithHttpInfo(user,); + Future createUser(User user, { Future? abortTrigger, }) async { + final response = await createUserWithHttpInfo(user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -76,7 +77,7 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInputWithHttpInfo(List user,) async { + Future createUsersWithArrayInputWithHttpInfo(List user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/createWithArray'; @@ -98,6 +99,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -109,8 +111,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInput(List user,) async { - final response = await createUsersWithArrayInputWithHttpInfo(user,); + Future createUsersWithArrayInput(List user, { Future? abortTrigger, }) async { + final response = await createUsersWithArrayInputWithHttpInfo(user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -126,7 +128,7 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInputWithHttpInfo(List user,) async { + Future createUsersWithListInputWithHttpInfo(List user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/createWithList'; @@ -148,6 +150,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -159,8 +162,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInput(List user,) async { - final response = await createUsersWithListInputWithHttpInfo(user,); + Future createUsersWithListInput(List user, { Future? abortTrigger, }) async { + final response = await createUsersWithListInputWithHttpInfo(user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -176,7 +179,7 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUserWithHttpInfo(String username,) async { + Future deleteUserWithHttpInfo(String username, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/{username}' .replaceAll('{username}', username); @@ -199,6 +202,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -210,8 +214,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUser(String username,) async { - final response = await deleteUserWithHttpInfo(username,); + Future deleteUser(String username, { Future? abortTrigger, }) async { + final response = await deleteUserWithHttpInfo(username, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -227,7 +231,7 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByNameWithHttpInfo(String username,) async { + Future getUserByNameWithHttpInfo(String username, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/{username}' .replaceAll('{username}', username); @@ -250,6 +254,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -261,8 +266,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByName(String username,) async { - final response = await getUserByNameWithHttpInfo(username,); + Future getUserByName(String username, { Future? abortTrigger, }) async { + final response = await getUserByNameWithHttpInfo(username, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -289,7 +294,7 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUserWithHttpInfo(String username, String password,) async { + Future loginUserWithHttpInfo(String username, String password, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/login'; @@ -314,6 +319,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -328,8 +334,8 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUser(String username, String password,) async { - final response = await loginUserWithHttpInfo(username, password,); + Future loginUser(String username, String password, { Future? abortTrigger, }) async { + final response = await loginUserWithHttpInfo(username, password, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -348,7 +354,7 @@ class UserApi { /// /// /// Note: This method returns the HTTP [Response]. - Future logoutUserWithHttpInfo() async { + Future logoutUserWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/logout'; @@ -370,14 +376,15 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } /// Logs out current logged in user session /// /// - Future logoutUser() async { - final response = await logoutUserWithHttpInfo(); + Future logoutUser({ Future? abortTrigger, }) async { + final response = await logoutUserWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -396,7 +403,7 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUserWithHttpInfo(String username, User user,) async { + Future updateUserWithHttpInfo(String username, User user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/{username}' .replaceAll('{username}', username); @@ -419,6 +426,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -433,8 +441,8 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUser(String username, User user,) async { - final response = await updateUserWithHttpInfo(username, user,); + Future updateUser(String username, User user, { Future? abortTrigger, }) async { + final response = await updateUserWithHttpInfo(username, user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart index 94edfa501db0..c95c46ef3b81 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart @@ -44,8 +44,9 @@ class ApiClient { Object? body, Map headerParams, Map formParams, - String? contentType, - ) async { + String? contentType, { + Future? abortTrigger, + }) async { await authentication?.applyToParams(queryParams, headerParams); headerParams.addAll(_defaultHeaderMap); @@ -63,7 +64,7 @@ class ApiClient { body is MultipartFile && (contentType == null || !contentType.toLowerCase().startsWith('multipart/form-data')) ) { - final request = StreamedRequest(method, uri); + final request = AbortableStreamedRequest(method, uri, abortTrigger: abortTrigger); request.headers.addAll(headerParams); request.contentLength = body.length; body.finalize().listen( @@ -78,7 +79,7 @@ class ApiClient { } if (body is MultipartRequest) { - final request = MultipartRequest(method, uri); + final request = AbortableMultipartRequest(method, uri, abortTrigger: abortTrigger); request.fields.addAll(body.fields); request.files.addAll(body.files); request.headers.addAll(body.headers); @@ -92,14 +93,19 @@ class ApiClient { : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; - switch(method) { - case 'POST': return await _client.post(uri, headers: nullableHeaderParams, body: msgBody,); - case 'PUT': return await _client.put(uri, headers: nullableHeaderParams, body: msgBody,); - case 'DELETE': return await _client.delete(uri, headers: nullableHeaderParams, body: msgBody,); - case 'PATCH': return await _client.patch(uri, headers: nullableHeaderParams, body: msgBody,); - case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,); - case 'GET': return await _client.get(uri, headers: nullableHeaderParams,); + final request = AbortableRequest(method, uri, abortTrigger: abortTrigger); + if (nullableHeaderParams != null) { + request.headers.addAll(nullableHeaderParams); } + if (msgBody is String && msgBody.isNotEmpty) { + request.body = msgBody; + } else if (msgBody is List && msgBody.isNotEmpty) { + request.bodyBytes = msgBody; + } else if (msgBody is Map) { + request.bodyFields = msgBody; + } + final response = await _client.send(request); + return Response.fromStream(response); } on SocketException catch (error, trace) { throw ApiException.withInner( HttpStatus.badRequest, @@ -136,11 +142,6 @@ class ApiClient { trace, ); } - - throw ApiException( - HttpStatus.badRequest, - 'Invalid HTTP operation: $method $path', - ); } Future deserializeAsync(String value, String targetType, {bool growable = false,}) async => diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart index 81ab2d859dda..99f53331d1cb 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart @@ -26,7 +26,7 @@ class AnotherFakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTagsWithHttpInfo(ModelClient modelClient,) async { + Future call123testSpecialTagsWithHttpInfo(ModelClient modelClient, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/another-fake/dummy'; @@ -48,6 +48,7 @@ class AnotherFakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -59,8 +60,8 @@ class AnotherFakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTags(ModelClient modelClient,) async { - final response = await call123testSpecialTagsWithHttpInfo(modelClient,); + Future call123testSpecialTags(ModelClient modelClient, { Future? abortTrigger, }) async { + final response = await call123testSpecialTagsWithHttpInfo(modelClient, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart index 059deb8d5e32..1a1381b03504 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart @@ -17,7 +17,7 @@ class DefaultApi { final ApiClient apiClient; /// Performs an HTTP 'GET /foo' operation and returns the [Response]. - Future fooGetWithHttpInfo() async { + Future fooGetWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/foo'; @@ -39,11 +39,12 @@ class DefaultApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } - Future fooGet() async { - final response = await fooGetWithHttpInfo(); + Future fooGet({ Future? abortTrigger, }) async { + final response = await fooGetWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart index 4d970ba6cf01..c61373a87937 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart @@ -19,7 +19,7 @@ class FakeApi { /// for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys /// /// Note: This method returns the HTTP [Response]. - Future fakeBigDecimalMapWithHttpInfo() async { + Future fakeBigDecimalMapWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/BigDecimalMap'; @@ -41,12 +41,13 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } /// for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys - Future fakeBigDecimalMap() async { - final response = await fakeBigDecimalMapWithHttpInfo(); + Future fakeBigDecimalMap({ Future? abortTrigger, }) async { + final response = await fakeBigDecimalMapWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -63,7 +64,7 @@ class FakeApi { /// test objects with duplicate inline enums see issue# 21582 /// /// Note: This method returns the HTTP [Response]. - Future fakeDuplicateInlineEnumWithHttpInfo() async { + Future fakeDuplicateInlineEnumWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/duplicate-inline-enums'; @@ -85,12 +86,13 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } /// test objects with duplicate inline enums see issue# 21582 - Future fakeDuplicateInlineEnum() async { - final response = await fakeDuplicateInlineEnumWithHttpInfo(); + Future fakeDuplicateInlineEnum({ Future? abortTrigger, }) async { + final response = await fakeDuplicateInlineEnumWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -107,7 +109,7 @@ class FakeApi { /// Health check endpoint /// /// Note: This method returns the HTTP [Response]. - Future fakeHealthGetWithHttpInfo() async { + Future fakeHealthGetWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/health'; @@ -129,12 +131,13 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } /// Health check endpoint - Future fakeHealthGet() async { - final response = await fakeHealthGetWithHttpInfo(); + Future fakeHealthGet({ Future? abortTrigger, }) async { + final response = await fakeHealthGetWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -162,7 +165,7 @@ class FakeApi { /// /// * [String] header1: /// header parameter - Future fakeHttpSignatureTestWithHttpInfo(Pet pet, { String? query1, String? header1, }) async { + Future fakeHttpSignatureTestWithHttpInfo(Pet pet, { String? query1, String? header1, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/http-signature-test'; @@ -192,6 +195,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -207,8 +211,8 @@ class FakeApi { /// /// * [String] header1: /// header parameter - Future fakeHttpSignatureTest(Pet pet, { String? query1, String? header1, }) async { - final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1, ); + Future fakeHttpSignatureTest(Pet pet, { String? query1, String? header1, Future? abortTrigger, }) async { + final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -222,7 +226,7 @@ class FakeApi { /// /// * [bool] body: /// Input boolean as post body - Future fakeOuterBooleanSerializeWithHttpInfo({ bool? body, }) async { + Future fakeOuterBooleanSerializeWithHttpInfo({ bool? body, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/outer/boolean'; @@ -244,6 +248,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -253,8 +258,8 @@ class FakeApi { /// /// * [bool] body: /// Input boolean as post body - Future fakeOuterBooleanSerialize({ bool? body, }) async { - final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body, ); + Future fakeOuterBooleanSerialize({ bool? body, Future? abortTrigger, }) async { + final response = await fakeOuterBooleanSerializeWithHttpInfo(body: body, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -276,7 +281,7 @@ class FakeApi { /// /// * [OuterComposite] outerComposite: /// Input composite as post body - Future fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite? outerComposite, }) async { + Future fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite? outerComposite, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/outer/composite'; @@ -298,6 +303,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -307,8 +313,8 @@ class FakeApi { /// /// * [OuterComposite] outerComposite: /// Input composite as post body - Future fakeOuterCompositeSerialize({ OuterComposite? outerComposite, }) async { - final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite, ); + Future fakeOuterCompositeSerialize({ OuterComposite? outerComposite, Future? abortTrigger, }) async { + final response = await fakeOuterCompositeSerializeWithHttpInfo(outerComposite: outerComposite, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -330,7 +336,7 @@ class FakeApi { /// /// * [num] body: /// Input number as post body - Future fakeOuterNumberSerializeWithHttpInfo({ num? body, }) async { + Future fakeOuterNumberSerializeWithHttpInfo({ num? body, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/outer/number'; @@ -352,6 +358,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -361,8 +368,8 @@ class FakeApi { /// /// * [num] body: /// Input number as post body - Future fakeOuterNumberSerialize({ num? body, }) async { - final response = await fakeOuterNumberSerializeWithHttpInfo( body: body, ); + Future fakeOuterNumberSerialize({ num? body, Future? abortTrigger, }) async { + final response = await fakeOuterNumberSerializeWithHttpInfo(body: body, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -384,7 +391,7 @@ class FakeApi { /// /// * [String] body: /// Input string as post body - Future fakeOuterStringSerializeWithHttpInfo({ String? body, }) async { + Future fakeOuterStringSerializeWithHttpInfo({ String? body, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/outer/string'; @@ -406,6 +413,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -415,8 +423,8 @@ class FakeApi { /// /// * [String] body: /// Input string as post body - Future fakeOuterStringSerialize({ String? body, }) async { - final response = await fakeOuterStringSerializeWithHttpInfo( body: body, ); + Future fakeOuterStringSerialize({ String? body, Future? abortTrigger, }) async { + final response = await fakeOuterStringSerializeWithHttpInfo(body: body, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -438,7 +446,7 @@ class FakeApi { /// /// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required): /// Input enum (int) as post body - Future fakePropertyEnumIntegerSerializeWithHttpInfo(OuterObjectWithEnumProperty outerObjectWithEnumProperty,) async { + Future fakePropertyEnumIntegerSerializeWithHttpInfo(OuterObjectWithEnumProperty outerObjectWithEnumProperty, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/property/enum-int'; @@ -460,6 +468,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -469,8 +478,8 @@ class FakeApi { /// /// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required): /// Input enum (int) as post body - Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty,) async { - final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty,); + Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty, { Future? abortTrigger, }) async { + final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -494,7 +503,7 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testAdditionalPropertiesReferenceWithHttpInfo(Map requestBody,) async { + Future testAdditionalPropertiesReferenceWithHttpInfo(Map requestBody, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/additionalProperties-reference'; @@ -516,6 +525,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -527,8 +537,8 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testAdditionalPropertiesReference(Map requestBody,) async { - final response = await testAdditionalPropertiesReferenceWithHttpInfo(requestBody,); + Future testAdditionalPropertiesReference(Map requestBody, { Future? abortTrigger, }) async { + final response = await testAdditionalPropertiesReferenceWithHttpInfo(requestBody, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -542,7 +552,7 @@ class FakeApi { /// /// * [MultipartFile] body (required): /// image to upload - Future testBodyWithBinaryWithHttpInfo(MultipartFile body,) async { + Future testBodyWithBinaryWithHttpInfo(MultipartFile body, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/body-with-binary'; @@ -564,6 +574,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -573,8 +584,8 @@ class FakeApi { /// /// * [MultipartFile] body (required): /// image to upload - Future testBodyWithBinary(MultipartFile body,) async { - final response = await testBodyWithBinaryWithHttpInfo(body,); + Future testBodyWithBinary(MultipartFile body, { Future? abortTrigger, }) async { + final response = await testBodyWithBinaryWithHttpInfo(body, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -587,7 +598,7 @@ class FakeApi { /// Parameters: /// /// * [FileSchemaTestClass] fileSchemaTestClass (required): - Future testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass,) async { + Future testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/body-with-file-schema'; @@ -609,6 +620,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -617,8 +629,8 @@ class FakeApi { /// Parameters: /// /// * [FileSchemaTestClass] fileSchemaTestClass (required): - Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass,) async { - final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass,); + Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass, { Future? abortTrigger, }) async { + final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -630,7 +642,7 @@ class FakeApi { /// * [String] query (required): /// /// * [User] user (required): - Future testBodyWithQueryParamsWithHttpInfo(String query, User user,) async { + Future testBodyWithQueryParamsWithHttpInfo(String query, User user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/body-with-query-params'; @@ -654,6 +666,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -662,8 +675,8 @@ class FakeApi { /// * [String] query (required): /// /// * [User] user (required): - Future testBodyWithQueryParams(String query, User user,) async { - final response = await testBodyWithQueryParamsWithHttpInfo(query, user,); + Future testBodyWithQueryParams(String query, User user, { Future? abortTrigger, }) async { + final response = await testBodyWithQueryParamsWithHttpInfo(query, user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -679,7 +692,7 @@ class FakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future testClientModelWithHttpInfo(ModelClient modelClient,) async { + Future testClientModelWithHttpInfo(ModelClient modelClient, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake'; @@ -701,6 +714,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -712,8 +726,8 @@ class FakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future testClientModel(ModelClient modelClient,) async { - final response = await testClientModelWithHttpInfo(modelClient,); + Future testClientModel(ModelClient modelClient, { Future? abortTrigger, }) async { + final response = await testClientModelWithHttpInfo(modelClient, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -776,7 +790,7 @@ class FakeApi { /// /// * [String] callback: /// None - Future testEndpointParametersWithHttpInfo(num number, double double_, String patternWithoutDelimiter, String byte, { int? integer, int? int32, int? int64, double? float, String? string, MultipartFile? binary, DateTime? date, DateTime? dateTime, String? password, String? callback, }) async { + Future testEndpointParametersWithHttpInfo(num number, double double_, String patternWithoutDelimiter, String byte, { int? integer, int? int32, int? int64, double? float, String? string, MultipartFile? binary, DateTime? date, DateTime? dateTime, String? password, String? callback, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake'; @@ -837,6 +851,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -887,8 +902,8 @@ class FakeApi { /// /// * [String] callback: /// None - Future testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int? integer, int? int32, int? int64, double? float, String? string, MultipartFile? binary, DateTime? date, DateTime? dateTime, String? password, String? callback, }) async { - final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback, ); + Future testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int? integer, int? int32, int? int64, double? float, String? string, MultipartFile? binary, DateTime? date, DateTime? dateTime, String? password, String? callback, Future? abortTrigger, }) async { + final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -927,7 +942,7 @@ class FakeApi { /// /// * [String] enumFormString: /// Form parameter enum test (string) - Future testEnumParametersWithHttpInfo({ List? enumHeaderStringArray, String? enumHeaderString, List? enumQueryStringArray, String? enumQueryString, int? enumQueryInteger, double? enumQueryDouble, List? enumQueryModelArray, List? enumFormStringArray, String? enumFormString, }) async { + Future testEnumParametersWithHttpInfo({ List? enumHeaderStringArray, String? enumHeaderString, List? enumQueryStringArray, String? enumQueryString, int? enumQueryInteger, double? enumQueryDouble, List? enumQueryModelArray, List? enumFormStringArray, String? enumFormString, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake'; @@ -978,6 +993,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1012,8 +1028,8 @@ class FakeApi { /// /// * [String] enumFormString: /// Form parameter enum test (string) - Future testEnumParameters({ List? enumHeaderStringArray, String? enumHeaderString, List? enumQueryStringArray, String? enumQueryString, int? enumQueryInteger, double? enumQueryDouble, List? enumQueryModelArray, List? enumFormStringArray, String? enumFormString, }) async { - final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumQueryModelArray: enumQueryModelArray, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString, ); + Future testEnumParameters({ List? enumHeaderStringArray, String? enumHeaderString, List? enumQueryStringArray, String? enumQueryString, int? enumQueryInteger, double? enumQueryDouble, List? enumQueryModelArray, List? enumFormStringArray, String? enumFormString, Future? abortTrigger, }) async { + final response = await testEnumParametersWithHttpInfo(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumQueryModelArray: enumQueryModelArray, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1044,7 +1060,7 @@ class FakeApi { /// /// * [int] int64Group: /// Integer in group parameters - Future testGroupParametersWithHttpInfo(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int? stringGroup, bool? booleanGroup, int? int64Group, }) async { + Future testGroupParametersWithHttpInfo(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int? stringGroup, bool? booleanGroup, int? int64Group, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake'; @@ -1080,6 +1096,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1106,8 +1123,8 @@ class FakeApi { /// /// * [int] int64Group: /// Integer in group parameters - Future testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int? stringGroup, bool? booleanGroup, int? int64Group, }) async { - final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group, ); + Future testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int? stringGroup, bool? booleanGroup, int? int64Group, Future? abortTrigger, }) async { + final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1123,7 +1140,7 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testInlineAdditionalPropertiesWithHttpInfo(Map requestBody,) async { + Future testInlineAdditionalPropertiesWithHttpInfo(Map requestBody, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/inline-additionalProperties'; @@ -1145,6 +1162,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1156,8 +1174,8 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testInlineAdditionalProperties(Map requestBody,) async { - final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody,); + Future testInlineAdditionalProperties(Map requestBody, { Future? abortTrigger, }) async { + final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1173,7 +1191,7 @@ class FakeApi { /// /// * [TestInlineFreeformAdditionalPropertiesRequest] testInlineFreeformAdditionalPropertiesRequest (required): /// request body - Future testInlineFreeformAdditionalPropertiesWithHttpInfo(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest,) async { + Future testInlineFreeformAdditionalPropertiesWithHttpInfo(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/inline-freeform-additionalProperties'; @@ -1195,6 +1213,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1206,8 +1225,8 @@ class FakeApi { /// /// * [TestInlineFreeformAdditionalPropertiesRequest] testInlineFreeformAdditionalPropertiesRequest (required): /// request body - Future testInlineFreeformAdditionalProperties(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest,) async { - final response = await testInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest,); + Future testInlineFreeformAdditionalProperties(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, { Future? abortTrigger, }) async { + final response = await testInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1226,7 +1245,7 @@ class FakeApi { /// /// * [String] param2 (required): /// field2 - Future testJsonFormDataWithHttpInfo(String param, String param2,) async { + Future testJsonFormDataWithHttpInfo(String param, String param2, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/jsonFormData'; @@ -1254,6 +1273,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1268,8 +1288,8 @@ class FakeApi { /// /// * [String] param2 (required): /// field2 - Future testJsonFormData(String param, String param2,) async { - final response = await testJsonFormDataWithHttpInfo(param, param2,); + Future testJsonFormData(String param, String param2, { Future? abortTrigger, }) async { + final response = await testJsonFormDataWithHttpInfo(param, param2, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1285,7 +1305,7 @@ class FakeApi { /// /// * [ChildWithNullable] childWithNullable (required): /// request body - Future testNullableWithHttpInfo(ChildWithNullable childWithNullable,) async { + Future testNullableWithHttpInfo(ChildWithNullable childWithNullable, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/nullable'; @@ -1307,6 +1327,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1318,8 +1339,8 @@ class FakeApi { /// /// * [ChildWithNullable] childWithNullable (required): /// request body - Future testNullable(ChildWithNullable childWithNullable,) async { - final response = await testNullableWithHttpInfo(childWithNullable,); + Future testNullable(ChildWithNullable childWithNullable, { Future? abortTrigger, }) async { + final response = await testNullableWithHttpInfo(childWithNullable, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1344,7 +1365,7 @@ class FakeApi { /// * [String] allowEmpty (required): /// /// * [Map] language: - Future testQueryParameterCollectionFormatWithHttpInfo(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map? language, }) async { + Future testQueryParameterCollectionFormatWithHttpInfo(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map? language, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/test-query-parameters'; @@ -1376,6 +1397,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1396,8 +1418,8 @@ class FakeApi { /// * [String] allowEmpty (required): /// /// * [Map] language: - Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map? language, }) async { - final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, allowEmpty, language: language, ); + Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map? language, Future? abortTrigger, }) async { + final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, allowEmpty, language: language, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1413,7 +1435,7 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testStringMapReferenceWithHttpInfo(Map requestBody,) async { + Future testStringMapReferenceWithHttpInfo(Map requestBody, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/stringMap-reference'; @@ -1435,6 +1457,7 @@ class FakeApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -1446,8 +1469,8 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testStringMapReference(Map requestBody,) async { - final response = await testStringMapReferenceWithHttpInfo(requestBody,); + Future testStringMapReference(Map requestBody, { Future? abortTrigger, }) async { + final response = await testStringMapReferenceWithHttpInfo(requestBody, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart index 7689f51b6884..4840ab8bbbd2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -26,7 +26,7 @@ class FakeClassnameTags123Api { /// /// * [ModelClient] modelClient (required): /// client model - Future testClassnameWithHttpInfo(ModelClient modelClient,) async { + Future testClassnameWithHttpInfo(ModelClient modelClient, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake_classname_test'; @@ -48,6 +48,7 @@ class FakeClassnameTags123Api { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -59,8 +60,8 @@ class FakeClassnameTags123Api { /// /// * [ModelClient] modelClient (required): /// client model - Future testClassname(ModelClient modelClient,) async { - final response = await testClassnameWithHttpInfo(modelClient,); + Future testClassname(ModelClient modelClient, { Future? abortTrigger, }) async { + final response = await testClassnameWithHttpInfo(modelClient, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart index 61fd1666af49..479ffbf55dfa 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart @@ -26,7 +26,7 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPetWithHttpInfo(Pet pet,) async { + Future addPetWithHttpInfo(Pet pet, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet'; @@ -48,6 +48,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -59,8 +60,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPet(Pet pet,) async { - final response = await addPetWithHttpInfo(pet,); + Future addPet(Pet pet, { Future? abortTrigger, }) async { + final response = await addPetWithHttpInfo(pet, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -78,7 +79,7 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePetWithHttpInfo(int petId, { String? apiKey, }) async { + Future deletePetWithHttpInfo(int petId, { String? apiKey, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}' .replaceAll('{petId}', petId.toString()); @@ -105,6 +106,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -118,8 +120,8 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePet(int petId, { String? apiKey, }) async { - final response = await deletePetWithHttpInfo(petId, apiKey: apiKey, ); + Future deletePet(int petId, { String? apiKey, Future? abortTrigger, }) async { + final response = await deletePetWithHttpInfo(petId, apiKey: apiKey, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -135,7 +137,7 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future findPetsByStatusWithHttpInfo(List status,) async { + Future findPetsByStatusWithHttpInfo(List status, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/findByStatus'; @@ -159,6 +161,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -170,8 +173,8 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future?> findPetsByStatus(List status,) async { - final response = await findPetsByStatusWithHttpInfo(status,); + Future?> findPetsByStatus(List status, { Future? abortTrigger, }) async { + final response = await findPetsByStatusWithHttpInfo(status, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -198,7 +201,7 @@ class PetApi { /// /// * [Set] tags (required): /// Tags to filter by - Future findPetsByTagsWithHttpInfo(Set tags,) async { + Future findPetsByTagsWithHttpInfo(Set tags, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/findByTags'; @@ -222,6 +225,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -233,8 +237,8 @@ class PetApi { /// /// * [Set] tags (required): /// Tags to filter by - Future?> findPetsByTags(Set tags,) async { - final response = await findPetsByTagsWithHttpInfo(tags,); + Future?> findPetsByTags(Set tags, { Future? abortTrigger, }) async { + final response = await findPetsByTagsWithHttpInfo(tags, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -261,7 +265,7 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetByIdWithHttpInfo(int petId,) async { + Future getPetByIdWithHttpInfo(int petId, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}' .replaceAll('{petId}', petId.toString()); @@ -284,6 +288,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -295,8 +300,8 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetById(int petId,) async { - final response = await getPetByIdWithHttpInfo(petId,); + Future getPetById(int petId, { Future? abortTrigger, }) async { + final response = await getPetByIdWithHttpInfo(petId, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -320,7 +325,7 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePetWithHttpInfo(Pet pet,) async { + Future updatePetWithHttpInfo(Pet pet, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet'; @@ -342,6 +347,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -353,8 +359,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePet(Pet pet,) async { - final response = await updatePetWithHttpInfo(pet,); + Future updatePet(Pet pet, { Future? abortTrigger, }) async { + final response = await updatePetWithHttpInfo(pet, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -376,7 +382,7 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithFormWithHttpInfo(int petId, { String? name, String? status, }) async { + Future updatePetWithFormWithHttpInfo(int petId, { String? name, String? status, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}' .replaceAll('{petId}', petId.toString()); @@ -405,6 +411,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -422,8 +429,8 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithForm(int petId, { String? name, String? status, }) async { - final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status, ); + Future updatePetWithForm(int petId, { String? name, String? status, Future? abortTrigger, }) async { + final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -445,7 +452,7 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFileWithHttpInfo(int petId, { String? additionalMetadata, MultipartFile? file, }) async { + Future uploadFileWithHttpInfo(int petId, { String? additionalMetadata, MultipartFile? file, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/pet/{petId}/uploadImage' .replaceAll('{petId}', petId.toString()); @@ -482,6 +489,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -499,8 +507,8 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFile(int petId, { String? additionalMetadata, MultipartFile? file, }) async { - final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file, ); + Future uploadFile(int petId, { String? additionalMetadata, MultipartFile? file, Future? abortTrigger, }) async { + final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -530,7 +538,7 @@ class PetApi { /// /// * [String] additionalMetadata: /// Additional data to pass to server - Future uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String? additionalMetadata, }) async { + Future uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String? additionalMetadata, Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/fake/{petId}/uploadImageWithRequiredFile' .replaceAll('{petId}', petId.toString()); @@ -567,6 +575,7 @@ class PetApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -584,8 +593,8 @@ class PetApi { /// /// * [String] additionalMetadata: /// Additional data to pass to server - Future uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String? additionalMetadata, }) async { - final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata, ); + Future uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String? additionalMetadata, Future? abortTrigger, }) async { + final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart index 7236e3de94fe..c73d9e711f6a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart @@ -26,7 +26,7 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrderWithHttpInfo(String orderId,) async { + Future deleteOrderWithHttpInfo(String orderId, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/order/{order_id}' .replaceAll('{order_id}', orderId); @@ -49,6 +49,7 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -60,8 +61,8 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrder(String orderId,) async { - final response = await deleteOrderWithHttpInfo(orderId,); + Future deleteOrder(String orderId, { Future? abortTrigger, }) async { + final response = await deleteOrderWithHttpInfo(orderId, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -72,7 +73,7 @@ class StoreApi { /// Returns a map of status codes to quantities /// /// Note: This method returns the HTTP [Response]. - Future getInventoryWithHttpInfo() async { + Future getInventoryWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/inventory'; @@ -94,14 +95,15 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } /// Returns pet inventories by status /// /// Returns a map of status codes to quantities - Future?> getInventory() async { - final response = await getInventoryWithHttpInfo(); + Future?> getInventory({ Future? abortTrigger, }) async { + final response = await getInventoryWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -125,7 +127,7 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderByIdWithHttpInfo(int orderId,) async { + Future getOrderByIdWithHttpInfo(int orderId, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/order/{order_id}' .replaceAll('{order_id}', orderId.toString()); @@ -148,6 +150,7 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -159,8 +162,8 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderById(int orderId,) async { - final response = await getOrderByIdWithHttpInfo(orderId,); + Future getOrderById(int orderId, { Future? abortTrigger, }) async { + final response = await getOrderByIdWithHttpInfo(orderId, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -184,7 +187,7 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrderWithHttpInfo(Order order,) async { + Future placeOrderWithHttpInfo(Order order, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/store/order'; @@ -206,6 +209,7 @@ class StoreApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -217,8 +221,8 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrder(Order order,) async { - final response = await placeOrderWithHttpInfo(order,); + Future placeOrder(Order order, { Future? abortTrigger, }) async { + final response = await placeOrderWithHttpInfo(order, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart index 4c59eb21f63e..e17392c958c2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart @@ -26,7 +26,7 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUserWithHttpInfo(User user,) async { + Future createUserWithHttpInfo(User user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user'; @@ -48,6 +48,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -59,8 +60,8 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUser(User user,) async { - final response = await createUserWithHttpInfo(user,); + Future createUser(User user, { Future? abortTrigger, }) async { + final response = await createUserWithHttpInfo(user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -76,7 +77,7 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInputWithHttpInfo(List user,) async { + Future createUsersWithArrayInputWithHttpInfo(List user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/createWithArray'; @@ -98,6 +99,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -109,8 +111,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInput(List user,) async { - final response = await createUsersWithArrayInputWithHttpInfo(user,); + Future createUsersWithArrayInput(List user, { Future? abortTrigger, }) async { + final response = await createUsersWithArrayInputWithHttpInfo(user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -126,7 +128,7 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInputWithHttpInfo(List user,) async { + Future createUsersWithListInputWithHttpInfo(List user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/createWithList'; @@ -148,6 +150,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -159,8 +162,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInput(List user,) async { - final response = await createUsersWithListInputWithHttpInfo(user,); + Future createUsersWithListInput(List user, { Future? abortTrigger, }) async { + final response = await createUsersWithListInputWithHttpInfo(user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -176,7 +179,7 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUserWithHttpInfo(String username,) async { + Future deleteUserWithHttpInfo(String username, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/{username}' .replaceAll('{username}', username); @@ -199,6 +202,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -210,8 +214,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUser(String username,) async { - final response = await deleteUserWithHttpInfo(username,); + Future deleteUser(String username, { Future? abortTrigger, }) async { + final response = await deleteUserWithHttpInfo(username, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -227,7 +231,7 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByNameWithHttpInfo(String username,) async { + Future getUserByNameWithHttpInfo(String username, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/{username}' .replaceAll('{username}', username); @@ -250,6 +254,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -261,8 +266,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByName(String username,) async { - final response = await getUserByNameWithHttpInfo(username,); + Future getUserByName(String username, { Future? abortTrigger, }) async { + final response = await getUserByNameWithHttpInfo(username, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -289,7 +294,7 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUserWithHttpInfo(String username, String password,) async { + Future loginUserWithHttpInfo(String username, String password, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/login'; @@ -314,6 +319,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -328,8 +334,8 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUser(String username, String password,) async { - final response = await loginUserWithHttpInfo(username, password,); + Future loginUser(String username, String password, { Future? abortTrigger, }) async { + final response = await loginUserWithHttpInfo(username, password, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -348,7 +354,7 @@ class UserApi { /// /// /// Note: This method returns the HTTP [Response]. - Future logoutUserWithHttpInfo() async { + Future logoutUserWithHttpInfo({ Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/logout'; @@ -370,14 +376,15 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } /// Logs out current logged in user session /// /// - Future logoutUser() async { - final response = await logoutUserWithHttpInfo(); + Future logoutUser({ Future? abortTrigger, }) async { + final response = await logoutUserWithHttpInfo(abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -396,7 +403,7 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUserWithHttpInfo(String username, User user,) async { + Future updateUserWithHttpInfo(String username, User user, { Future? abortTrigger, }) async { // ignore: prefer_const_declarations final path = r'/user/{username}' .replaceAll('{username}', username); @@ -419,6 +426,7 @@ class UserApi { headerParams, formParams, contentTypes.isEmpty ? null : contentTypes.first, + abortTrigger: abortTrigger, ); } @@ -433,8 +441,8 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUser(String username, User user,) async { - final response = await updateUserWithHttpInfo(username, user,); + Future updateUser(String username, User user, { Future? abortTrigger, }) async { + final response = await updateUserWithHttpInfo(username, user, abortTrigger: abortTrigger,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart index 7deaf18cebeb..1b24b08b6ad2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart @@ -44,8 +44,9 @@ class ApiClient { Object? body, Map headerParams, Map formParams, - String? contentType, - ) async { + String? contentType, { + Future? abortTrigger, + }) async { await authentication?.applyToParams(queryParams, headerParams); headerParams.addAll(_defaultHeaderMap); @@ -63,7 +64,7 @@ class ApiClient { body is MultipartFile && (contentType == null || !contentType.toLowerCase().startsWith('multipart/form-data')) ) { - final request = StreamedRequest(method, uri); + final request = AbortableStreamedRequest(method, uri, abortTrigger: abortTrigger); request.headers.addAll(headerParams); request.contentLength = body.length; body.finalize().listen( @@ -78,7 +79,7 @@ class ApiClient { } if (body is MultipartRequest) { - final request = MultipartRequest(method, uri); + final request = AbortableMultipartRequest(method, uri, abortTrigger: abortTrigger); request.fields.addAll(body.fields); request.files.addAll(body.files); request.headers.addAll(body.headers); @@ -92,14 +93,19 @@ class ApiClient { : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; - switch(method) { - case 'POST': return await _client.post(uri, headers: nullableHeaderParams, body: msgBody,); - case 'PUT': return await _client.put(uri, headers: nullableHeaderParams, body: msgBody,); - case 'DELETE': return await _client.delete(uri, headers: nullableHeaderParams, body: msgBody,); - case 'PATCH': return await _client.patch(uri, headers: nullableHeaderParams, body: msgBody,); - case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,); - case 'GET': return await _client.get(uri, headers: nullableHeaderParams,); + final request = AbortableRequest(method, uri, abortTrigger: abortTrigger); + if (nullableHeaderParams != null) { + request.headers.addAll(nullableHeaderParams); } + if (msgBody is String && msgBody.isNotEmpty) { + request.body = msgBody; + } else if (msgBody is List && msgBody.isNotEmpty) { + request.bodyBytes = msgBody; + } else if (msgBody is Map) { + request.bodyFields = msgBody; + } + final response = await _client.send(request); + return Response.fromStream(response); } on SocketException catch (error, trace) { throw ApiException.withInner( HttpStatus.badRequest, @@ -136,11 +142,6 @@ class ApiClient { trace, ); } - - throw ApiException( - HttpStatus.badRequest, - 'Invalid HTTP operation: $method $path', - ); } Future deserializeAsync(String value, String targetType, {bool growable = false,}) async =>