forked from loafle/openapi-generator-original
Generate auth files to correct location
This commit is contained in:
parent
e72a53448e
commit
58c5ecf13c
@ -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"));
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -2,5 +2,6 @@ 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user