Skip to content

Commit 6a4aead

Browse files
feat: Add documentation for generated service constructors (#2575)
Signed-off-by: Brian Quinlan <[email protected]> Co-authored-by: Nate Bosch <[email protected]>
1 parent 3060b07 commit 6a4aead

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

internal/sidekick/internal/dart/templates/lib/service.mustache

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,27 @@ final class {{Codec.Name}} {
2121
static const _host = '{{DefaultHost}}';
2222
final ServiceClient _client;
2323
24+
/// Creates a `{{Codec.Name}}` using [client] for transport.
25+
///
26+
/// The provided [http.Client] must be configured to provide whatever
27+
/// authentication is required by `{{Codec.Name}}`. You can do that
28+
/// using
29+
/// [`package:googleapis_auth`](https://pub.dev/packages/googleapis_auth).
2430
{{Codec.Name}}({required http.Client client})
2531
: _client = ServiceClient(client: client);
2632

33+
/// Creates a `{{Codec.Name}}` that does authentication through an API key.
34+
///
35+
/// If called without arguments, the API key is taken from these environment
36+
/// variables:
37+
{{#Model.Codec.ApiKeyEnvironmentVariables}}
38+
/// * `{{{.}}}`
39+
{{/Model.Codec.ApiKeyEnvironmentVariables}}
40+
///
41+
/// Throws [ArgumentError] if called without arguments and none of the above
42+
/// environment variables are set.
43+
///
44+
/// See [API Keys Overview](https://cloud.google.com/api-keys/docs/overview).
2745
factory {{Codec.Name}}.fromApiKey([String? apiKey]) {
2846
apiKey ??= _apiKeys.map(environmentVariable).nonNulls.firstOrNull;
2947
if (apiKey == null) {

0 commit comments

Comments
 (0)