forked from loafle/openapi-generator-original
[Dart 2] Add support for Dart 2 (#754)
* Add an option for Dart2 * add dart2 samples, update travis * fix dart installation * Upper constraints on the SDK version * Update dependencies * supportDart2 option can now be passed through --additional-properties * Update petstore tests * Update dart2-petstore.sh * Running tests on Dart VM * Fixed JSON deserialization bugs * Fixed missing initialization of postBody * Run bin/dart2-petstore.sh to regenerate libraries * Update pom.xml * Added SDK version constraints in pubspec.mustache * Run bin/dart2-petstore.sh to regenerate libraries * move dart2 test to the end
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
part of openapi.api;
|
||||
|
||||
class ApiKeyAuth implements Authentication {
|
||||
|
||||
final String location;
|
||||
final String paramName;
|
||||
String apiKey;
|
||||
String apiKeyPrefix;
|
||||
|
||||
ApiKeyAuth(this.location, this.paramName);
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
String value;
|
||||
if (apiKeyPrefix != null) {
|
||||
value = '$apiKeyPrefix $apiKey';
|
||||
} else {
|
||||
value = apiKey;
|
||||
}
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
part of openapi.api;
|
||||
|
||||
abstract class Authentication {
|
||||
|
||||
/// Apply authentication settings to header and query params.
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
part of openapi.api;
|
||||
|
||||
class HttpBasicAuth implements Authentication {
|
||||
|
||||
String username;
|
||||
String password;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||
headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
part of openapi.api;
|
||||
|
||||
class OAuth implements Authentication {
|
||||
String accessToken;
|
||||
|
||||
OAuth({this.accessToken});
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (accessToken != null) {
|
||||
headerParams["Authorization"] = "Bearer " + accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user