Skip to content

Commit bcc12e6

Browse files
committed
fix: Fixed bug with pattern status codes like 4XX.
1 parent a358a29 commit bcc12e6

File tree

548 files changed

+35572
-3815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

548 files changed

+35572
-3815
lines changed

src/libs/AutoSDK/Models/EndPointResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ TypeData Type
1818
public bool Is5XX => StatusCode.StartsWith("5", StringComparison.OrdinalIgnoreCase);
1919
public bool IsDefault => StatusCode == "default";
2020
public bool IsPattern => StatusCode.Contains("XX");
21+
public int Min => int.TryParse(StatusCode.Replace("XX", "00"), out var code) ? code : 0;
22+
public int Max => int.TryParse(StatusCode.Replace("XX", "99"), out var code) ? code : 0;
2123

2224
public static EndPointResponse Default => new(
2325
StatusCode: "200",

src/libs/AutoSDK/Sources/Sources.Methods.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,11 @@ public static string GenerateResponse(
401401

402402
var errors = endPoint.Settings.GenerateExceptions ? orderedErrorResponses.Select(x => $@"
403403
// {x.Description.Replace('\n', ' ').Replace('\r', ' ')}
404-
{(x.IsDefault ? @"
405-
if (!__response.IsSuccessStatusCode)" : @$"
404+
{( x.IsDefault ? @"
405+
if (!__response.IsSuccessStatusCode)"
406+
: x.IsPattern ? $@"
407+
if ((int)__response.StatusCode >= {x.Min} && (int)__response.StatusCode <= {x.Max})"
408+
: @$"
406409
if ((int)__response.StatusCode == {x.StatusCode})")}
407410
{{
408411
string? __content_{x.StatusCode} = null;

src/tests/AutoSDK.SnapshotTests/Snapshots/anthropic/NewtonsoftJson/_#G.Api.g.verified.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace G
66
{
77
/// <summary>
8-
/// API Spec for Anthropic API. Please see https://docs.anthropic.com/en/api for more details.<br/>
98
/// If no httpClient is provided, a new one will be created.<br/>
109
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
1110
/// </summary>
@@ -38,6 +37,33 @@ public sealed partial class Api : global::G.IApi, global::System.IDisposable
3837
public global::Newtonsoft.Json.JsonSerializerSettings JsonSerializerOptions { get; set; } = new global::Newtonsoft.Json.JsonSerializerSettings();
3938

4039

40+
/// <summary>
41+
///
42+
/// </summary>
43+
public MessagesClient Messages => new MessagesClient(HttpClient, authorizations: Authorizations)
44+
{
45+
ReadResponseAsString = ReadResponseAsString,
46+
JsonSerializerOptions = JsonSerializerOptions,
47+
};
48+
49+
/// <summary>
50+
///
51+
/// </summary>
52+
public TextCompletionsClient TextCompletions => new TextCompletionsClient(HttpClient, authorizations: Authorizations)
53+
{
54+
ReadResponseAsString = ReadResponseAsString,
55+
JsonSerializerOptions = JsonSerializerOptions,
56+
};
57+
58+
/// <summary>
59+
///
60+
/// </summary>
61+
public MessageBatchesClient MessageBatches => new MessageBatchesClient(HttpClient, authorizations: Authorizations)
62+
{
63+
ReadResponseAsString = ReadResponseAsString,
64+
JsonSerializerOptions = JsonSerializerOptions,
65+
};
66+
4167
/// <summary>
4268
/// Creates a new instance of the Api.
4369
/// If no httpClient is provided, a new one will be created.

src/tests/AutoSDK.SnapshotTests/Snapshots/anthropic/NewtonsoftJson/_#G.IApi.CreateMessage.g.verified.cs

Lines changed: 0 additions & 245 deletions
This file was deleted.

src/tests/AutoSDK.SnapshotTests/Snapshots/anthropic/NewtonsoftJson/_#G.IApi.CreateMessageBatch.g.verified.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/tests/AutoSDK.SnapshotTests/Snapshots/anthropic/NewtonsoftJson/_#G.IApi.RetrieveMessageBatch.g.verified.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/tests/AutoSDK.SnapshotTests/Snapshots/anthropic/NewtonsoftJson/_#G.IApi.g.verified.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace G
66
{
77
/// <summary>
8-
/// API Spec for Anthropic API. Please see https://docs.anthropic.com/en/api for more details.<br/>
98
/// If no httpClient is provided, a new one will be created.<br/>
109
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
1110
/// </summary>
@@ -38,5 +37,20 @@ public partial interface IApi : global::System.IDisposable
3837
global::Newtonsoft.Json.JsonSerializerSettings JsonSerializerOptions { get; set; }
3938

4039

40+
/// <summary>
41+
///
42+
/// </summary>
43+
public MessagesClient Messages { get; }
44+
45+
/// <summary>
46+
///
47+
/// </summary>
48+
public TextCompletionsClient TextCompletions { get; }
49+
50+
/// <summary>
51+
///
52+
/// </summary>
53+
public MessageBatchesClient MessageBatches { get; }
54+
4155
}
4256
}

0 commit comments

Comments
 (0)