Generate auth files to correct location

This commit is contained in:
Yissachar Radcliffe 2015-09-06 19:58:28 -04:00
parent e72a53448e
commit 58c5ecf13c
6 changed files with 4 additions and 61 deletions

View File

@ -133,7 +133,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("apiException.mustache", libFolder, "api_exception.dart"));
supportingFiles.add(new SupportingFile("apilib.mustache", libFolder, "api.dart"));
final String authFolder = sourceFolder + File.separator + "auth";
final String authFolder = sourceFolder + File.separator + "lib" + File.separator + "auth";
supportingFiles.add(new SupportingFile("auth/authentication.mustache", authFolder, "authentication.dart"));
supportingFiles.add(new SupportingFile("auth/http_basic_auth.mustache", authFolder, "http_basic_auth.dart"));
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));

View File

@ -1,28 +0,0 @@
part of api;
class ApiKeyAuth implements Authentication {
final String location;
final String paramName;
String apiKey;
String apiKeyPrefix;
ApiKeyAuth(this.location, this.paramName);
@override
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
String value;
if (apiKeyPrefix != null) {
value = '$apiKeyPrefix $apiKey';
} else {
value = apiKey;
}
if (location == 'query' && value != null) {
queryParams[paramName] = value;
} else if (location == 'header' && value != null) {
headerParams[paramName] = value;
}
}
}

View File

@ -1,7 +0,0 @@
part of api;
abstract class Authentication {
/// Apply authentication settings to header and query params.
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams);
}

View File

@ -1,14 +0,0 @@
part of api;
class HttpBasicAuth implements Authentication {
String username;
String password;
@override
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
headerParams["Authorization"] = "Basic " + CryptoUtils.bytesToBase64(UTF8.encode(str));
}
}

View File

@ -1,9 +0,0 @@
part of api;
class OAuth implements Authentication {
@override
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
// TODO: support oauth
}
}

View File

@ -1,6 +1,7 @@
part of api;
abstract class Authentication {
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams);
/// Apply authentication settings to header and query params.
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams);
}