Skip to content

Commit

Permalink
fix: Fixed some issues with langsmith json OpenAPI 3.1 spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 12, 2024
1 parent 6716d2e commit 325a222
Show file tree
Hide file tree
Showing 603 changed files with 19,756 additions and 2,482 deletions.
2 changes: 1 addition & 1 deletion src/libs/AutoSDK/Extensions/OpenApiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static OpenApiDocument GetOpenApiDocument(

var openApiDocument = new OpenApiStringReader(new OpenApiReaderSettings
{
RuleSet = ValidationRuleSet.GetDefaultRuleSet(),
RuleSet = ValidationRuleSet.GetEmptyRuleSet(),
}).Read(yamlOrJson, out var diagnostics);
if (!settings.IgnoreOpenApiErrors && diagnostics.Errors.Any())
{
Expand Down
21 changes: 21 additions & 0 deletions src/libs/AutoSDK/Helpers/OpenApi31Support.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ entry.Value is JsonArray typeList &&
}
}

if (keyString == "ge")
{
node.Remove(keyString);
node["minimum"] = entry.Value?.DeepClone();
}
if (keyString == "le")
{
node.Remove(keyString);
node["maximum"] = entry.Value?.DeepClone();
}

// Remove "prefixItems"
if (keyString == "prefixItems" && entry.Value is JsonArray { Count: > 0 } prefixItemsList)
{
node.Remove(keyString);
if (!node.ContainsKey("items"))
{
node["items"] = prefixItemsList[0]?.DeepClone();
}
}

// Replace "examples" with single "example"
if (keyString == "examples" && entry.Value is JsonArray { Count: > 0 } examplesList)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//HintName: G.AceClient.Execute.g.cs

#nullable enable

namespace G
{
public partial class AceClient
{
partial void PrepareExecuteArguments(
global::System.Net.Http.HttpClient httpClient,
global::G.BodyExecuteApiV1AceExecutePost request);
partial void PrepareExecuteRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
global::G.BodyExecuteApiV1AceExecutePost request);
partial void ProcessExecuteResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessExecuteResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// Execute<br/>
/// Execute some custom code for testing purposes.
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<object> ExecuteAsync(
global::G.BodyExecuteApiV1AceExecutePost request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareExecuteArguments(
httpClient: _httpClient,
request: request);

var __pathBuilder = new PathBuilder(
path: "/api/v1/ace/execute",
baseUri: _httpClient.BaseAddress);
var __path = __pathBuilder.ToString();
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));

foreach (var _authorization in _authorizations)
{
if (_authorization.Type == "Http" ||
_authorization.Type == "OAuth2")
{
httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: _authorization.Name,
parameter: _authorization.Value);
}
else if (_authorization.Type == "ApiKey" &&
_authorization.Location == "Header")
{
httpRequest.Headers.Add(_authorization.Name, _authorization.Value);
}
}
var __httpRequestContentBody = global::Newtonsoft.Json.JsonConvert.SerializeObject(request, JsonSerializerOptions);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareExecuteRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
request: request);

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

ProcessResponse(
client: _httpClient,
response: response);
ProcessExecuteResponse(
httpClient: _httpClient,
httpResponseMessage: response);

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

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessExecuteResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

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

return
global::Newtonsoft.Json.JsonConvert.DeserializeObject<object?>(__content, JsonSerializerOptions) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}

/// <summary>
/// Execute<br/>
/// Execute some custom code for testing purposes.
/// </summary>
/// <param name="args"></param>
/// <param name="code"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<object> ExecuteAsync(
global::System.Collections.Generic.IList<global::G.BodyExecuteApiV1AceExecutePostArg> args,
string code,
global::System.Threading.CancellationToken cancellationToken = default)
{
var request = new global::G.BodyExecuteApiV1AceExecutePost
{
Args = args,
Code = code,
};

return await ExecuteAsync(
request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Loading

0 comments on commit 325a222

Please sign in to comment.