Skip to content

Commit

Permalink
fix: Now some schemas will be Dictionary or just objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 11, 2024
1 parent 8db773c commit f57f27f
Show file tree
Hide file tree
Showing 246 changed files with 3,641 additions and 2,612 deletions.
594 changes: 307 additions & 287 deletions specs/ollama.yaml

Large diffs are not rendered by default.

18 changes: 7 additions & 11 deletions src/libs/AutoSDK/Models/TypeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,11 @@ public static string GetCSharpType(SchemaContext context)
(_, _) when context.Schema.IsOneOf() => $"global::{context.Settings.Namespace}.OneOf<{string.Join(", ", context.Children.Where(x => x.Hint == Hint.OneOf).Select(x => x.TypeData?.CSharpTypeWithNullabilityForValueTypes))}>",
(_, _) when context.Schema.IsAllOf() => $"global::{context.Settings.Namespace}.AllOf<{string.Join(", ", context.Children.Where(x => x.Hint == Hint.AllOf).Select(x => x.TypeData?.CSharpTypeWithNullabilityForValueTypes))}>",

("object", _) or (null, _) when context.Schema.Reference != null =>
("object", _) or (null, _) when
context.Schema.Reference != null &&
(context.Schema.ResolveIfRequired().Properties.Count > 0 ||
!context.Schema.ResolveIfRequired().AdditionalPropertiesAllowed) =>
$"global::{context.Settings.Namespace}.{context.Id}",

// ("object", _) or (null, _) when
// context.Schema.Reference != null &&
// (context.Schema.ResolveIfRequired().Properties.Count > 0 ||
// !context.Schema.ResolveIfRequired().AdditionalPropertiesAllowed) =>
// $"global::{context.Settings.Namespace}.{context.Id}",

("object", _) or (null, "object") when context.Schema.Reference == null =>
$"global::{context.Settings.Namespace}.{context.Id}",
Expand All @@ -240,10 +237,9 @@ public static string GetCSharpType(SchemaContext context)
// !context.Schema.AdditionalPropertiesAllowed) =>
// $"global::{context.Settings.Namespace}.{context.Id}",

// ("object", _) when
// context.Schema.Reference == null &&
// context.Schema.AdditionalProperties?.Type is not (null or "object") =>
// $"global::System.Collections.Generic.Dictionary<string, {context.Children.FirstOrDefault(x => x.Hint == Hint.AdditionalProperties)?.TypeData?.CSharpType}>",
("object", _) when
context.Schema.AdditionalProperties?.Type is not null =>
$"global::System.Collections.Generic.Dictionary<string, {context.Children.FirstOrDefault(x => x.Hint == Hint.AdditionalProperties)?.TypeData?.CSharpType}>",

("string", _) when context.Schema.Enum.Any() =>
$"global::{context.Settings.Namespace}.{context.Id}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ partial void ProcessDeleteConnectorResponseContent(
/// <param name="xClientName"></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<global::G.DeleteConnectorResponse> DeleteConnectorAsync(
public async global::System.Threading.Tasks.Task<object> DeleteConnectorAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -116,7 +116,7 @@ partial void ProcessDeleteConnectorResponseContent(
}

return
global::Newtonsoft.Json.JsonConvert.DeserializeObject<global::G.DeleteConnectorResponse?>(__content, JsonSerializerOptions) ??
global::Newtonsoft.Json.JsonConvert.DeserializeObject<object?>(__content, JsonSerializerOptions) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ partial void ProcessDeleteFinetunedModelResponseContent(
/// <param name="xClientName"></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<global::G.DeleteFinetunedModelResponse> DeleteFinetunedModelAsync(
public async global::System.Threading.Tasks.Task<object> DeleteFinetunedModelAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -115,7 +115,7 @@ partial void ProcessDeleteFinetunedModelResponseContent(
}

return
global::Newtonsoft.Json.JsonConvert.DeserializeObject<global::G.DeleteFinetunedModelResponse?>(__content, JsonSerializerOptions) ??
global::Newtonsoft.Json.JsonConvert.DeserializeObject<object?>(__content, JsonSerializerOptions) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial interface IConnectorsClient
/// <param name="xClientName"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::G.DeleteConnectorResponse> DeleteConnectorAsync(
global::System.Threading.Tasks.Task<object> DeleteConnectorAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial interface IFinetuningClient
/// <param name="xClientName"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::G.DeleteFinetunedModelResponse> DeleteFinetunedModelAsync(
global::System.Threading.Tasks.Task<object> DeleteFinetunedModelAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ partial void ProcessDeleteConnectorResponseContent(
/// <param name="xClientName"></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<global::G.DeleteConnectorResponse> DeleteConnectorAsync(
public async global::System.Threading.Tasks.Task<object> DeleteConnectorAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -116,7 +116,7 @@ partial void ProcessDeleteConnectorResponseContent(
}

return
global::System.Text.Json.JsonSerializer.Deserialize<global::G.DeleteConnectorResponse?>(__content, JsonSerializerOptions) ??
global::System.Text.Json.JsonSerializer.Deserialize<object?>(__content, JsonSerializerOptions) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ partial void ProcessDeleteFinetunedModelResponseContent(
/// <param name="xClientName"></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<global::G.DeleteFinetunedModelResponse> DeleteFinetunedModelAsync(
public async global::System.Threading.Tasks.Task<object> DeleteFinetunedModelAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -115,7 +115,7 @@ partial void ProcessDeleteFinetunedModelResponseContent(
}

return
global::System.Text.Json.JsonSerializer.Deserialize<global::G.DeleteFinetunedModelResponse?>(__content, JsonSerializerOptions) ??
global::System.Text.Json.JsonSerializer.Deserialize<object?>(__content, JsonSerializerOptions) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial interface IConnectorsClient
/// <param name="xClientName"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::G.DeleteConnectorResponse> DeleteConnectorAsync(
global::System.Threading.Tasks.Task<object> DeleteConnectorAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial interface IFinetuningClient
/// <param name="xClientName"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::G.DeleteFinetunedModelResponse> DeleteFinetunedModelAsync(
global::System.Threading.Tasks.Task<object> DeleteFinetunedModelAsync(
string id,
string? xClientName = default,
global::System.Threading.CancellationToken cancellationToken = default);
Expand Down
Loading

0 comments on commit f57f27f

Please sign in to comment.