mirror of
https://github.com/hanzo-dart/sdk.git
synced 2026-10-30 19:32:47 +00:00
2479 operations over 1814 paths become 192 API classes and 2460 models, generated by hanzoai/openapi's driver from hanzoai/cloud openapi.yaml at the commit .spec-lock names. `dart` and not `dart-dio`: dart-dio's models declare 2460 `.g.dart` parts that only build_runner writes, so the package does not parse until a second code generator has run — output this driver neither invokes nor owns. The `dart` generator serializes in one pass over package:http, which is the transport hanzo-dart/hanzoai and hanzo-dart/base already speak. lib/hanzoai.dart is the only hand-written file under lib/: the front door, `hanzo()`, and a re-export. The driver owns the files it wrote, so it survives regeneration. dart pub get && dart analyze && dart test pass, and example/models.dart runs against api.hanzo.ai with no credential.
41 lines
1.1 KiB
Dart
41 lines
1.1 KiB
Dart
//
|
|
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
|
//
|
|
// @dart=2.18
|
|
|
|
// ignore_for_file: unused_element, unused_import
|
|
// ignore_for_file: always_put_required_named_parameters_first
|
|
// ignore_for_file: constant_identifier_names
|
|
// ignore_for_file: lines_longer_than_80_chars
|
|
|
|
part of hanzoai.cloud;
|
|
|
|
class ApiKeyAuth implements Authentication {
|
|
ApiKeyAuth(this.location, this.paramName);
|
|
|
|
final String location;
|
|
final String paramName;
|
|
|
|
String apiKeyPrefix = '';
|
|
String apiKey = '';
|
|
|
|
@override
|
|
Future<void> applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams,) async {
|
|
final paramValue = apiKeyPrefix.isEmpty ? apiKey : '$apiKeyPrefix $apiKey';
|
|
|
|
if (paramValue.isNotEmpty) {
|
|
if (location == 'query') {
|
|
queryParams.add(QueryParam(paramName, paramValue));
|
|
} else if (location == 'header') {
|
|
headerParams[paramName] = paramValue;
|
|
} else if (location == 'cookie') {
|
|
headerParams.update(
|
|
'Cookie',
|
|
(existingCookie) => '$existingCookie; $paramName=$paramValue',
|
|
ifAbsent: () => '$paramName=$paramValue',
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|