Skip to content

Commit

Permalink
feat: Added generated constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Aug 24, 2024
1 parent a5d265a commit 5948aab
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
```csharp
using Leonardo;

using var api = new LeonardoApi();
api.AuthorizeUsingBearer(apiKey);
using var api = new LeonardoApi(apiKey);

var createResponse = await api.Image.CreateGenerationAsync(
prompt: "Generate cat");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#nullable enable

namespace Leonardo
{
public sealed partial class LeonardoApi
{
/// <inheritdoc cref="LeonardoApi(global::System.Net.Http.HttpClient?, global::System.Uri?)"/>
public LeonardoApi(
string apiKey,
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null) : this(httpClient, baseUri)
{
AuthorizeUsingBearer(apiKey);
}
}
}
3 changes: 2 additions & 1 deletion src/libs/Leonardo/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ oag generate openapi.yaml \
--namespace Leonardo \
--clientClassName LeonardoApi \
--targetFramework net8.0 \
--output Generated
--output Generated \
--exclude-deprecated-operations
3 changes: 1 addition & 2 deletions src/tests/Leonardo.IntegrationTests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public static LeonardoApi GetAuthorizedApi()
Environment.GetEnvironmentVariable("LEONARDO_API_KEY") ??
throw new AssertInconclusiveException("LEONARDO_API_KEY environment variable is not found.");

var api = new LeonardoApi();
api.AuthorizeUsingBearer(apiKey);
var api = new LeonardoApi(apiKey);

return api;
}
Expand Down

0 comments on commit 5948aab

Please sign in to comment.