Skip to content

Commit

Permalink
feat: Updated OpenAPI spec
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 23, 2024
1 parent c832f53 commit d744c7e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 37 deletions.
15 changes: 15 additions & 0 deletions src/libs/Tavily/Generated/Tavily.ITavilyClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ namespace Tavily
/// </summary>
public partial interface ITavilyClient : global::System.IDisposable
{
/// <summary>
/// The HttpClient instance.
/// </summary>
public global::System.Net.Http.HttpClient HttpClient { get; }

/// <summary>
/// The base URL for the API.
/// </summary>
public System.Uri? BaseUri { get; }

/// <summary>
/// The authorizations to use for the requests.
/// </summary>
public global::System.Collections.Generic.List<global::Tavily.EndPointAuthorization> Authorizations { get; }

/// <summary>
///
/// </summary>
Expand Down
50 changes: 25 additions & 25 deletions src/libs/Tavily/Generated/Tavily.TavilyClient.Search.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,63 +34,63 @@ partial void ProcessSearchResponseContent(
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
client: HttpClient);
PrepareSearchArguments(
httpClient: _httpClient,
httpClient: HttpClient,
request: request);

var __pathBuilder = new PathBuilder(
path: "/search",
baseUri: _httpClient.BaseAddress);
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
__httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: _httpClient,
request: httpRequest);
client: HttpClient,
request: __httpRequest);
PrepareSearchRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
request: request);

using var response = await _httpClient.SendAsync(
request: httpRequest,
using var __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
client: HttpClient,
response: __response);
ProcessSearchResponse(
httpClient: _httpClient,
httpResponseMessage: response);
httpClient: HttpClient,
httpResponseMessage: __response);

var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
client: HttpClient,
response: __response,
content: ref __content);
ProcessSearchResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
httpClient: HttpClient,
httpResponseMessage: __response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException ex)
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::System.InvalidOperationException(__content, ex);
throw new global::System.InvalidOperationException(__content, __ex);
}

return
Expand Down Expand Up @@ -149,7 +149,7 @@ partial void ProcessSearchResponseContent(
global::System.Collections.Generic.IList<string>? excludeDomains = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var request = new global::Tavily.SearchRequest
var __request = new global::Tavily.SearchRequest
{
ApiKey = apiKey,
Query = query,
Expand All @@ -163,7 +163,7 @@ partial void ProcessSearchResponseContent(
};

return await SearchAsync(
request: request,
request: __request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
Expand Down
38 changes: 26 additions & 12 deletions src/libs/Tavily/Generated/Tavily.TavilyClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ public sealed partial class TavilyClient : global::Tavily.ITavilyClient, global:
/// <summary>
///
/// </summary>
public const string BaseUrl = "https://api.tavily.com";
public const string DefaultBaseUrl = "https://api.tavily.com";

private readonly global::System.Net.Http.HttpClient _httpClient;
private global::System.Collections.Generic.List<global::Tavily.EndPointAuthorization> _authorizations;
private bool _disposeHttpClient = true;

/// <inheritdoc/>
public global::System.Net.Http.HttpClient HttpClient { get; }

/// <inheritdoc/>
public System.Uri? BaseUri => HttpClient.BaseAddress;

/// <inheritdoc/>
public global::System.Collections.Generic.List<global::Tavily.EndPointAuthorization> Authorizations { get; }

/// <summary>
///
Expand All @@ -29,25 +37,31 @@ public sealed partial class TavilyClient : global::Tavily.ITavilyClient, global:
/// If no httpClient is provided, a new one will be created.
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
/// <param name="httpClient"></param>
/// <param name="baseUri"></param>
/// <param name="authorizations"></param>
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
/// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
/// <param name="authorizations">The authorizations to use for the requests.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public TavilyClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::Tavily.EndPointAuthorization>? authorizations = null)
global::System.Collections.Generic.List<global::Tavily.EndPointAuthorization>? authorizations = null,
bool disposeHttpClient = true)
{
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_authorizations = authorizations ?? new global::System.Collections.Generic.List<global::Tavily.EndPointAuthorization>();
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List<global::Tavily.EndPointAuthorization>();
_disposeHttpClient = disposeHttpClient;

Initialized(_httpClient);
Initialized(HttpClient);
}

/// <inheritdoc/>
public void Dispose()
{
_httpClient.Dispose();
if (_disposeHttpClient)
{
HttpClient.Dispose();
}
}

partial void Initialized(
Expand Down

0 comments on commit d744c7e

Please sign in to comment.