-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: Expose only OpenApiGenerator generated code.
- Loading branch information
Showing
72 changed files
with
4,040 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
src/libs/Ollama.Models/Generated/OpenApiGenerator/OpenApiGenerator.SdkGenerator/AnyOf.2.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
using System.Linq; | ||
|
||
#nullable enable | ||
|
||
namespace System | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public readonly struct AnyOf<T1, T2> : global::System.IEquatable<AnyOf<T1, T2>> | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
#if NET6_0_OR_GREATER | ||
public T1? Value1 { get; init; } | ||
#else | ||
public T1? Value1 { get; } | ||
#endif | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
#if NET6_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value1))] | ||
#endif | ||
public bool IsValue1 => Value1 != null; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static implicit operator AnyOf<T1, T2>(T1 value) => new AnyOf<T1, T2>(value); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static implicit operator T1?(AnyOf<T1, T2> @this) => @this.Value1; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public AnyOf(T1? value) | ||
{ | ||
Value1 = value; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
#if NET6_0_OR_GREATER | ||
public T2? Value2 { get; init; } | ||
#else | ||
public T2? Value2 { get; } | ||
#endif | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
#if NET6_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))] | ||
#endif | ||
public bool IsValue2 => Value2 != null; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static implicit operator AnyOf<T1, T2>(T2 value) => new AnyOf<T1, T2>(value); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static implicit operator T2?(AnyOf<T1, T2> @this) => @this.Value2; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public AnyOf(T2? value) | ||
{ | ||
Value2 = value; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public AnyOf( | ||
T1? value1, | ||
T2? value2 | ||
) | ||
{ | ||
Value1 = value1; | ||
Value2 = value2; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public object? Object => | ||
Value2 as object ?? | ||
Value1 as object | ||
; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public bool Validate() | ||
{ | ||
return IsValue1 || IsValue2; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public override int GetHashCode() | ||
{ | ||
var fields = new object?[] | ||
{ | ||
Value1, | ||
typeof(T1), | ||
Value2, | ||
typeof(T2), | ||
}; | ||
const int offset = unchecked((int)2166136261); | ||
const int prime = 16777619; | ||
static int HashCodeAggregator(int hashCode, object? value) => value == null | ||
? (hashCode ^ 0) * prime | ||
: (hashCode ^ value.GetHashCode()) * prime; | ||
return fields.Aggregate(offset, HashCodeAggregator); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public bool Equals(AnyOf<T1, T2> other) | ||
{ | ||
return | ||
global::System.Collections.Generic.EqualityComparer<T1?>.Default.Equals(Value1, other.Value1) && | ||
global::System.Collections.Generic.EqualityComparer<T2?>.Default.Equals(Value2, other.Value2) | ||
; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static bool operator ==(AnyOf<T1, T2> obj1, AnyOf<T1, T2> obj2) | ||
{ | ||
return global::System.Collections.Generic.EqualityComparer<AnyOf<T1, T2>>.Default.Equals(obj1, obj2); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static bool operator !=(AnyOf<T1, T2> obj1, AnyOf<T1, T2> obj2) | ||
{ | ||
return !(obj1 == obj2); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public override bool Equals(object? obj) | ||
{ | ||
return obj is AnyOf<T1, T2> o && Equals(o); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...odels/Generated/OpenApiGenerator/OpenApiGenerator.SdkGenerator/JsonConverters.AnyOf2.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#nullable enable | ||
|
||
namespace OpenApiGenerator.JsonConverters | ||
{ | ||
/// <inheritdoc /> | ||
public class AnyOfJsonConverter<T1, T2> : global::System.Text.Json.Serialization.JsonConverter<global::System.AnyOf<T1, T2>> | ||
{ | ||
/// <inheritdoc /> | ||
public override global::System.AnyOf<T1, T2> Read( | ||
ref global::System.Text.Json.Utf8JsonReader reader, | ||
global::System.Type typeToConvert, | ||
global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
var | ||
readerCopy = reader; | ||
T1? value1 = default; | ||
try | ||
{ | ||
value1 = global::System.Text.Json.JsonSerializer.Deserialize<T1>(ref readerCopy, options); | ||
} | ||
catch (global::System.Text.Json.JsonException) | ||
{ | ||
} | ||
|
||
readerCopy = reader; | ||
T2? value2 = default; | ||
try | ||
{ | ||
value2 = global::System.Text.Json.JsonSerializer.Deserialize<T2>(ref readerCopy, options); | ||
} | ||
catch (global::System.Text.Json.JsonException) | ||
{ | ||
} | ||
var result = new global::System.AnyOf<T1, T2>( | ||
value1, | ||
|
||
value2 | ||
); | ||
if (!result.Validate()) | ||
{ | ||
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(T1).Name}, {typeof(T2).Name}>"); | ||
} | ||
|
||
if (value1 != null) | ||
{ | ||
_ = global::System.Text.Json.JsonSerializer.Deserialize<T1>(ref reader, options); | ||
} | ||
|
||
else if (value2 != null) | ||
{ | ||
_ = global::System.Text.Json.JsonSerializer.Deserialize<T2>(ref reader, options); | ||
} | ||
return result; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Write( | ||
global::System.Text.Json.Utf8JsonWriter writer, | ||
global::System.AnyOf<T1, T2> value, | ||
global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
if (!value.Validate()) | ||
{ | ||
throw new global::System.Text.Json.JsonException($"Invalid AnyOf<{typeof(T1).Name}, {typeof(T2).Name}> object."); | ||
} | ||
|
||
if (value.IsValue1) | ||
{ | ||
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1, value.Value1!.GetType(), options); | ||
} | ||
|
||
else if (value.IsValue2) | ||
{ | ||
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value2, value.Value2!.GetType(), options); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...enerated/OpenApiGenerator/OpenApiGenerator.SdkGenerator/JsonConverters.AnyOfFactory2.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#nullable enable | ||
|
||
namespace OpenApiGenerator.JsonConverters | ||
{ | ||
/// <inheritdoc /> | ||
public sealed class AnyOfJsonConverterFactory2 : global::System.Text.Json.Serialization.JsonConverterFactory | ||
{ | ||
/// <inheritdoc /> | ||
public override bool CanConvert(global::System.Type? typeToConvert) | ||
{ | ||
return typeToConvert is { IsGenericType: true } && typeToConvert.GetGenericTypeDefinition() == typeof(global::System.AnyOf<,>); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override global::System.Text.Json.Serialization.JsonConverter CreateConverter( | ||
global::System.Type typeToConvert, | ||
global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
typeToConvert = typeToConvert ?? throw new global::System.ArgumentNullException(nameof(typeToConvert)); | ||
|
||
return (global::System.Text.Json.Serialization.JsonConverter)global::System.Activator.CreateInstance( | ||
typeof(AnyOfJsonConverter<,>).MakeGenericType(typeToConvert.GenericTypeArguments))!; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...nApiGenerator/OpenApiGenerator.SdkGenerator/JsonConverters.CreateModelResponseStatus.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#nullable enable | ||
|
||
namespace OpenApiGenerator.JsonConverters | ||
{ | ||
/// <inheritdoc /> | ||
public sealed class CreateModelResponseStatusJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelResponseStatus> | ||
{ | ||
/// <inheritdoc /> | ||
public override global::Ollama.CreateModelResponseStatus Read( | ||
ref global::System.Text.Json.Utf8JsonReader reader, | ||
global::System.Type typeToConvert, | ||
global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
switch (reader.TokenType) | ||
{ | ||
case global::System.Text.Json.JsonTokenType.String: | ||
{ | ||
var stringValue = reader.GetString(); | ||
if (stringValue != null) | ||
{ | ||
return global::Ollama.CreateModelResponseStatusExtensions.ToEnum(stringValue) ?? default; | ||
} | ||
|
||
break; | ||
} | ||
case global::System.Text.Json.JsonTokenType.Number: | ||
{ | ||
var numValue = reader.GetInt32(); | ||
return (global::Ollama.CreateModelResponseStatus)numValue; | ||
} | ||
default: | ||
throw new global::System.ArgumentOutOfRangeException(nameof(reader)); | ||
} | ||
|
||
return default; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Write( | ||
global::System.Text.Json.Utf8JsonWriter writer, | ||
global::Ollama.CreateModelResponseStatus value, | ||
global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); | ||
|
||
writer.WriteStringValue(global::Ollama.CreateModelResponseStatusExtensions.ToValueString(value)); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...rator/OpenApiGenerator.SdkGenerator/JsonConverters.CreateModelResponseStatusNullable.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#nullable enable | ||
|
||
namespace OpenApiGenerator.JsonConverters | ||
{ | ||
/// <inheritdoc /> | ||
public sealed class CreateModelResponseStatusNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelResponseStatus?> | ||
{ | ||
/// <inheritdoc /> | ||
public override global::Ollama.CreateModelResponseStatus? Read( | ||
ref global::System.Text.Json.Utf8JsonReader reader, | ||
global::System.Type typeToConvert, | ||
global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
switch (reader.TokenType) | ||
{ | ||
case global::System.Text.Json.JsonTokenType.String: | ||
{ | ||
var stringValue = reader.GetString(); | ||
if (stringValue != null) | ||
{ | ||
return global::Ollama.CreateModelResponseStatusExtensions.ToEnum(stringValue); | ||
} | ||
|
||
break; | ||
} | ||
case global::System.Text.Json.JsonTokenType.Number: | ||
{ | ||
var numValue = reader.GetInt32(); | ||
return (global::Ollama.CreateModelResponseStatus)numValue; | ||
} | ||
default: | ||
throw new global::System.ArgumentOutOfRangeException(nameof(reader)); | ||
} | ||
|
||
return default; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Write( | ||
global::System.Text.Json.Utf8JsonWriter writer, | ||
global::Ollama.CreateModelResponseStatus? value, | ||
global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); | ||
|
||
if (value == null) | ||
{ | ||
writer.WriteNullValue(); | ||
} | ||
else | ||
{ | ||
writer.WriteStringValue(global::Ollama.CreateModelResponseStatusExtensions.ToValueString(value.Value)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.