-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:Updated OpenAPI spec #29
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,29 +39,25 @@ public class DoneReasonJsonConverter : global::System.Text.Json.Serialization.Js | |
catch (global::System.Text.Json.JsonException) | ||
{ | ||
} | ||
|
||
var result = new global::Ollama.DoneReason( | ||
value1, | ||
|
||
value2 | ||
); | ||
if (!result.Validate()) | ||
{ | ||
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(string).Name}, {typeof(global::Ollama.DoneReasonEnum).Name}>"); | ||
} | ||
|
||
if (value1 != null) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(string), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<string> ?? | ||
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(string).Name}"); | ||
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); | ||
} | ||
|
||
else if (value2 != null) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.DoneReasonEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.DoneReasonEnum> ?? | ||
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.DoneReasonEnum).Name}"); | ||
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); | ||
} | ||
|
||
Comment on lines
+42
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reevaluate the removal of validation checks for reliability. The removal of validation checks in the deserialization process can result in invalid data being processed without triggering exceptions. This change might affect the reliability of the application by allowing potentially inconsistent data to propagate through the system. Consider implementing alternative validation mechanisms to ensure data consistency and reliability. |
||
return result; | ||
} | ||
|
||
|
@@ -74,18 +70,12 @@ public override void Write( | |
options = options ?? throw new global::System.ArgumentNullException(nameof(options)); | ||
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); | ||
|
||
if (!value.Validate()) | ||
{ | ||
throw new global::System.Text.Json.JsonException($"Invalid AnyOf<{typeof(string).Name}, {typeof(global::Ollama.DoneReasonEnum).Name}> object."); | ||
} | ||
|
||
if (value.IsValue1) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(string), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<string?> ?? | ||
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(string).Name}"); | ||
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1, typeInfo); | ||
} | ||
|
||
else if (value.IsValue2) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.DoneReasonEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.DoneReasonEnum?> ?? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,29 +39,25 @@ public class PullModelStatusJsonConverter : global::System.Text.Json.Serializati | |
catch (global::System.Text.Json.JsonException) | ||
{ | ||
} | ||
|
||
var result = new global::Ollama.PullModelStatus( | ||
value1, | ||
|
||
value2 | ||
); | ||
if (!result.Validate()) | ||
{ | ||
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(string).Name}, {typeof(global::Ollama.PullModelStatusEnum).Name}>"); | ||
} | ||
|
||
if (value1 != null) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(string), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<string> ?? | ||
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(string).Name}"); | ||
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); | ||
} | ||
|
||
else if (value2 != null) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.PullModelStatusEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.PullModelStatusEnum> ?? | ||
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.PullModelStatusEnum).Name}"); | ||
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); | ||
} | ||
|
||
Comment on lines
+42
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assess the impact of removing validation checks on system stability. The removal of validation checks in the deserialization process may lead to invalid data being processed without error handling, which could compromise system stability. This change might allow inconsistent data to be serialized and deserialized without triggering exceptions. Consider reintroducing validation mechanisms to maintain data integrity and ensure system stability. |
||
return result; | ||
} | ||
|
||
|
@@ -74,18 +70,12 @@ public override void Write( | |
options = options ?? throw new global::System.ArgumentNullException(nameof(options)); | ||
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); | ||
|
||
if (!value.Validate()) | ||
{ | ||
throw new global::System.Text.Json.JsonException($"Invalid AnyOf<{typeof(string).Name}, {typeof(global::Ollama.PullModelStatusEnum).Name}> object."); | ||
} | ||
|
||
if (value.IsValue1) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(string), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<string?> ?? | ||
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(string).Name}"); | ||
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1, typeInfo); | ||
} | ||
|
||
else if (value.IsValue2) | ||
{ | ||
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.PullModelStatusEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.PullModelStatusEnum?> ?? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider reintroducing validation checks for data integrity.
The removal of validation checks in the deserialization process can lead to potential issues with handling invalid data. Without these checks, invalid data might be silently accepted, which could cause downstream errors or inconsistencies.
Consider reintroducing some form of validation to ensure data integrity and prevent potential issues.