diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_client.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_client.mustache index d0cc2dfb2096..edbe692d4cc3 100644 --- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_client.mustache @@ -46,22 +46,62 @@ class {{clientName}} { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } + } + + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } }{{#apiInfo}}{{#apis}} /// Get {{classname}} instance, base route and serializer can be overridden by a given but be careful, diff --git a/samples/openapi3/client/petstore/dart-dio/binary_response/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/binary_response/lib/src/api.dart index 8943da413f65..d6c329a1f6a2 100644 --- a/samples/openapi3/client/petstore/dart-dio/binary_response/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio/binary_response/lib/src/api.dart @@ -42,24 +42,64 @@ class Openapi { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } + } + /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed DefaultApi getDefaultApi() { diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart index dfd8e847bdd9..3951a530bcd6 100644 --- a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart @@ -47,24 +47,64 @@ class Openapi { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } + } + /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed DefaultApi getDefaultApi() { diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api.dart index 3e6abb37ddb9..44446906c9b3 100644 --- a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api.dart @@ -48,24 +48,64 @@ class Openapi { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } + } + /// Get BarApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed BarApi getBarApi() { diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api.dart index 7eb05e3ea4e6..b0413ea8fa33 100644 --- a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api.dart @@ -47,24 +47,64 @@ class Openapi { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } + } + /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed DefaultApi getDefaultApi() { diff --git a/samples/openapi3/client/petstore/dart-dio/petstore-timemachine/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/petstore-timemachine/lib/src/api.dart index 43d2a2a08b13..1807483f79d2 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore-timemachine/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore-timemachine/lib/src/api.dart @@ -49,24 +49,64 @@ class Openapi { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } + } + /// Get PetApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed PetApi getPetApi() { diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api.dart index 835b76584b2d..4009d71ad3b5 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api.dart @@ -48,24 +48,64 @@ class Openapi { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } + } + /// Get AnotherFakeApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed AnotherFakeApi getAnotherFakeApi() { diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api.dart index 53d0c5a524bb..df659eb2f2a2 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api.dart @@ -53,24 +53,64 @@ class Openapi { } } + /// Removes the OAuth token associated with the given [name]. + /// + /// If no [OAuthInterceptor] is registered or no token exists for the given + /// [name], this method has no effect. + void removeOAuthToken(String name) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens.remove(name); + } + } + void setBearerAuth(String name, String token) { if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; } } + /// Removes the bearer authentication token associated with the given [name]. + /// + /// If no [BearerAuthInterceptor] is registered or no token exists for the + /// given [name], this method has no effect. + void removeBearerAuth(String name) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens.remove(name); + } + } + void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } + /// Removes the basic authentication credentials associated with the given [name]. + /// + /// If no [BasicAuthInterceptor] is registered or no credentials exist for the + /// given [name], this method has no effect. + void removeBasicAuth(String name) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo.remove(name); + } + } + void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } + /// Removes the API key associated with the given [name]. + /// + /// If no [ApiKeyAuthInterceptor] is registered or no API key exists for the + /// given [name], this method has no effect. + void removeApiKey(String name) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys.remove(name); + } + } + /// Get AnotherFakeApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed AnotherFakeApi getAnotherFakeApi() {