Skip to content

Commit 462afa7

Browse files
committed
fix: Fixed missing default values for query parameters.
1 parent a9c4583 commit 462afa7

File tree

1,472 files changed

+5172
-5170
lines changed

Some content is hidden

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

1,472 files changed

+5172
-5170
lines changed

src/libs/OpenApiGenerator.Core/Generation/Sources.Methods.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ public static string GenerateMethod(
117117
/// <exception cref=""global::System.InvalidOperationException""></exception>
118118
{(endPoint.IsDeprecated ? "[global::System.Obsolete(\"This method marked as deprecated.\")]" : " ")}
119119
public async {taskType} {endPoint.MethodName}(
120-
{endPoint.Properties.Where(x => x.ParameterLocation != null).Select(x => $@"
120+
{endPoint.Properties.Where(x => x is { ParameterLocation: not null, IsRequired: true }).Select(x => $@"
121121
{x.Type.CSharpType} {x.ParameterName},").Inject()}
122122
{(string.IsNullOrWhiteSpace(endPoint.RequestType.CSharpType) ? " " : @$"
123123
{endPoint.RequestType.CSharpTypeWithoutNullability} request,")}
124+
{endPoint.Properties.Where(x => x is { ParameterLocation: not null, IsRequired: false }).Select(x => $@"
125+
{x.Type.CSharpType} {x.ParameterName} = {x.ParameterDefaultValue},").Inject()}
124126
{cancellationTokenAttribute}global::System.Threading.CancellationToken cancellationToken = default)
125127
{{
126128
{(string.IsNullOrWhiteSpace(endPoint.RequestType.CSharpType) || endPoint.RequestType.IsAnyOf ? " " : @"

src/libs/OpenApiGenerator.Core/Models/TypeData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public static string GetCSharpType(SchemaContext context, SchemaContext? additio
220220
("integer", "int64") => ("long", false),
221221
("number", "float") => ("float", false),
222222
("number", "double") => ("double", false),
223-
("string", "byte") => ("byte[]", false),
223+
("string", "byte") => ("byte[]", true),
224224
("string", "binary") => ("byte[]", true),
225225
("string", "date") => ("global::System.DateTime", false),
226226
("string", "date-time") => ("global::System.DateTime", false),

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.ChatClient.V1J2UltraChat.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ partial void ProcessV1J2UltraChatResponseContent(
3434
/// <param name="cancellationToken">The token to cancel the operation with</param>
3535
/// <exception cref="global::System.InvalidOperationException"></exception>
3636
public async global::System.Threading.Tasks.Task<global::G.ChatResponse> V1J2UltraChatAsync(
37-
string? model,
3837
global::G.LanguageStudioApiServerDataTypesJ2ChatChatRequest request,
38+
string? model = "j2-ultra",
3939
global::System.Threading.CancellationToken cancellationToken = default)
4040
{
4141
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.V1J2GrandeComplete.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ partial void ProcessV1J2GrandeCompleteResponseContent(
3434
/// <param name="cancellationToken">The token to cancel the operation with</param>
3535
/// <exception cref="global::System.InvalidOperationException"></exception>
3636
public async global::System.Threading.Tasks.Task<global::G.V1J2GrandeCompleteResponse> V1J2GrandeCompleteAsync(
37-
string? model,
3837
global::G.CompletionBody request,
38+
string? model = "j2-grande",
3939
global::System.Threading.CancellationToken cancellationToken = default)
4040
{
4141
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.V1J2GrandeCustomModelComplete.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ partial void ProcessV1J2GrandeCustomModelCompleteResponseContent(
3838
/// <exception cref="global::System.InvalidOperationException"></exception>
3939
public async global::System.Threading.Tasks.Task<global::G.V1J2GrandeCustomModelCompleteResponse> V1J2GrandeCustomModelCompleteAsync(
4040
string customModelName,
41-
string? customModelType,
4241
global::G.CompletionBody request,
42+
string? customModelType = "j2-grande",
4343
global::System.Threading.CancellationToken cancellationToken = default)
4444
{
4545
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.V1J2GrandeInstructComplete.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ partial void ProcessV1J2GrandeInstructCompleteResponseContent(
3434
/// <param name="cancellationToken">The token to cancel the operation with</param>
3535
/// <exception cref="global::System.InvalidOperationException"></exception>
3636
public async global::System.Threading.Tasks.Task<global::G.V1J2GrandeInstructCompleteResponse> V1J2GrandeInstructCompleteAsync(
37-
string? model,
3837
global::G.CompletionBody request,
38+
string? model = "j2-grande-instruct",
3939
global::System.Threading.CancellationToken cancellationToken = default)
4040
{
4141
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.V1J2JumboComplete.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ partial void ProcessV1J2JumboCompleteResponseContent(
3434
/// <param name="cancellationToken">The token to cancel the operation with</param>
3535
/// <exception cref="global::System.InvalidOperationException"></exception>
3636
public async global::System.Threading.Tasks.Task<global::G.V1J2JumboCompleteResponse> V1J2JumboCompleteAsync(
37-
string? model,
3837
global::G.CompletionBody request,
38+
string? model = "j2-jumbo",
3939
global::System.Threading.CancellationToken cancellationToken = default)
4040
{
4141
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.V1J2JumboComplete2.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ partial void ProcessV1J2JumboComplete2ResponseContent(
3838
/// <exception cref="global::System.InvalidOperationException"></exception>
3939
public async global::System.Threading.Tasks.Task<global::G.V1J2JumboCompleteResponse2> V1J2JumboComplete2Async(
4040
string customModelName,
41-
string? customModelType,
4241
global::G.CompletionBody request,
42+
string? customModelType = "j2-jumbo",
4343
global::System.Threading.CancellationToken cancellationToken = default)
4444
{
4545
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.V1J2JumboInstructComplete.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ partial void ProcessV1J2JumboInstructCompleteResponseContent(
3434
/// <param name="cancellationToken">The token to cancel the operation with</param>
3535
/// <exception cref="global::System.InvalidOperationException"></exception>
3636
public async global::System.Threading.Tasks.Task<global::G.V1J2JumboInstructCompleteResponse> V1J2JumboInstructCompleteAsync(
37-
string? model,
3837
global::G.CompletionBody request,
38+
string? model = "j2-jumbo-instruct",
3939
global::System.Threading.CancellationToken cancellationToken = default)
4040
{
4141
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.V1J2LargeComplete.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ partial void ProcessV1J2LargeCompleteResponseContent(
3434
/// <param name="cancellationToken">The token to cancel the operation with</param>
3535
/// <exception cref="global::System.InvalidOperationException"></exception>
3636
public async global::System.Threading.Tasks.Task<global::G.V1J2LargeCompleteResponse> V1J2LargeCompleteAsync(
37-
string? model,
3837
global::G.CompletionBody request,
38+
string? model = "j2-large",
3939
global::System.Threading.CancellationToken cancellationToken = default)
4040
{
4141
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

0 commit comments

Comments
 (0)