Skip to content

Commit

Permalink
fix: Fixed bug with pattern status codes like 4XX.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Dec 8, 2024
1 parent a358a29 commit bcc12e6
Show file tree
Hide file tree
Showing 548 changed files with 35,572 additions and 3,815 deletions.
2 changes: 2 additions & 0 deletions src/libs/AutoSDK/Models/EndPointResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ TypeData Type
public bool Is5XX => StatusCode.StartsWith("5", StringComparison.OrdinalIgnoreCase);
public bool IsDefault => StatusCode == "default";
public bool IsPattern => StatusCode.Contains("XX");
public int Min => int.TryParse(StatusCode.Replace("XX", "00"), out var code) ? code : 0;
public int Max => int.TryParse(StatusCode.Replace("XX", "99"), out var code) ? code : 0;

public static EndPointResponse Default => new(
StatusCode: "200",
Expand Down
7 changes: 5 additions & 2 deletions src/libs/AutoSDK/Sources/Sources.Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,11 @@ public static string GenerateResponse(

var errors = endPoint.Settings.GenerateExceptions ? orderedErrorResponses.Select(x => $@"
// {x.Description.Replace('\n', ' ').Replace('\r', ' ')}
{(x.IsDefault ? @"
if (!__response.IsSuccessStatusCode)" : @$"
{( x.IsDefault ? @"
if (!__response.IsSuccessStatusCode)"
: x.IsPattern ? $@"
if ((int)__response.StatusCode >= {x.Min} && (int)__response.StatusCode <= {x.Max})"
: @$"
if ((int)__response.StatusCode == {x.StatusCode})")}
{{
string? __content_{x.StatusCode} = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace G
{
/// <summary>
/// API Spec for Anthropic API. Please see https://docs.anthropic.com/en/api for more details.<br/>
/// If no httpClient is provided, a new one will be created.<br/>
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
Expand Down Expand Up @@ -38,6 +37,33 @@ public sealed partial class Api : global::G.IApi, global::System.IDisposable
public global::Newtonsoft.Json.JsonSerializerSettings JsonSerializerOptions { get; set; } = new global::Newtonsoft.Json.JsonSerializerSettings();


/// <summary>
///
/// </summary>
public MessagesClient Messages => new MessagesClient(HttpClient, authorizations: Authorizations)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
///
/// </summary>
public TextCompletionsClient TextCompletions => new TextCompletionsClient(HttpClient, authorizations: Authorizations)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
///
/// </summary>
public MessageBatchesClient MessageBatches => new MessageBatchesClient(HttpClient, authorizations: Authorizations)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
/// Creates a new instance of the Api.
/// If no httpClient is provided, a new one will be created.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace G
{
/// <summary>
/// API Spec for Anthropic API. Please see https://docs.anthropic.com/en/api for more details.<br/>
/// If no httpClient is provided, a new one will be created.<br/>
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
Expand Down Expand Up @@ -38,5 +37,20 @@ public partial interface IApi : global::System.IDisposable
global::Newtonsoft.Json.JsonSerializerSettings JsonSerializerOptions { get; set; }


/// <summary>
///
/// </summary>
public MessagesClient Messages { get; }

/// <summary>
///
/// </summary>
public TextCompletionsClient TextCompletions { get; }

/// <summary>
///
/// </summary>
public MessageBatchesClient MessageBatches { get; }

}
}
Loading

0 comments on commit bcc12e6

Please sign in to comment.