Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Comment thread
nopjar marked this conversation as resolved.
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
40 changes: 40 additions & 0 deletions samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading
Loading