diff --git a/src/apps/OpenApiGenerator.Cli/Commands/GenerateCommand.cs b/src/apps/OpenApiGenerator.Cli/Commands/GenerateCommand.cs index aea5735043..0d3088e38e 100644 --- a/src/apps/OpenApiGenerator.Cli/Commands/GenerateCommand.cs +++ b/src/apps/OpenApiGenerator.Cli/Commands/GenerateCommand.cs @@ -53,6 +53,7 @@ private static async Task HandleAsync(string inputPath, string outputPath, strin Namespace: @namespace, ClassName: clientClassName, NamingConvention: default, + JsonSerializerType: default, IncludeOperationIds: [], GenerateModels: true, ModelStyle: default, diff --git a/src/libs/Directory.Build.props b/src/libs/Directory.Build.props index 7584e05cbd..305169ccbf 100644 --- a/src/libs/Directory.Build.props +++ b/src/libs/Directory.Build.props @@ -39,7 +39,7 @@ - 0.1.5 + 0.2.0 0.1 v dev diff --git a/src/libs/OpenApiGenerator.Core/Extensions/OpenApiExtensions.cs b/src/libs/OpenApiGenerator.Core/Extensions/OpenApiExtensions.cs index b68135d1ec..9d8d90aa1f 100644 --- a/src/libs/OpenApiGenerator.Core/Extensions/OpenApiExtensions.cs +++ b/src/libs/OpenApiGenerator.Core/Extensions/OpenApiExtensions.cs @@ -2,6 +2,7 @@ using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; +using OpenApiGenerator.Core.Json; using OpenApiGenerator.Core.Models; namespace OpenApiGenerator.Core.Extensions; @@ -37,8 +38,11 @@ public static string GetCSharpType( (null, _) when schema.Value.OneOf.Any() => ("object", true), (null, _) when schema.Value.AllOf.Any() => ("object", true), - ("string", _) when schema.Value.Enum.Any() => + // Only Newtonsoft.Json supports EnumMemberAttribute + ("string", _) when schema.Value.Enum.Any() && settings.JsonSerializerType == JsonSerializerType.NewtonsoftJson => ($"{(model with { Style = ModelStyle.Enumeration }).ExternalClassName}", true), + ("string", _) when schema.Value.Enum.Any() && settings.JsonSerializerType != JsonSerializerType.NewtonsoftJson => + ("string", true), ("boolean", _) => ("bool", false), ("integer", "int32") => ("int", false), diff --git a/src/libs/OpenApiGenerator.Core/Generation/Sources.Models.cs b/src/libs/OpenApiGenerator.Core/Generation/Sources.Models.cs index 6cb25ece2b..4a88037b68 100644 --- a/src/libs/OpenApiGenerator.Core/Generation/Sources.Models.cs +++ b/src/libs/OpenApiGenerator.Core/Generation/Sources.Models.cs @@ -1,4 +1,5 @@ using OpenApiGenerator.Core.Extensions; +using OpenApiGenerator.Core.Json; using OpenApiGenerator.Core.Models; namespace OpenApiGenerator.Core.Generation; @@ -45,7 +46,10 @@ public static string GenerateEnumerationModel( ModelData modelData, CancellationToken cancellationToken = default) { - return $@" + // Only Newtonsoft.Json supports EnumMemberAttribute + if (modelData.JsonSerializerType == JsonSerializerType.NewtonsoftJson) + { + return $@" {modelData.Summary.ToXmlDocumentationSummary(level: 4)} [global::System.Runtime.Serialization.DataContract] public enum {modelData.ClassName} @@ -55,6 +59,17 @@ public enum {modelData.ClassName} [global::System.Runtime.Serialization.EnumMember(Value=""{property.Id}"")] {property.Name}, ").Inject()} + }}".RemoveBlankLinesWhereOnlyWhitespaces(); + } + + return $@" + {modelData.Summary.ToXmlDocumentationSummary(level: 4)} + public abstract class {modelData.ClassName} + {{ +{modelData.Properties.Select(property => @$" + {property.Summary.ToXmlDocumentationSummary(level: 8)} + public const string {property.Name} = ""{property.Id}""; + ").Inject()} }}".RemoveBlankLinesWhereOnlyWhitespaces(); } @@ -62,18 +77,20 @@ public static string GenerateClassModel( ModelData modelData, CancellationToken cancellationToken = default) { + var jsonSerializer = modelData.JsonSerializerType.GetSerializer(); + return $@" {modelData.Summary.ToXmlDocumentationSummary(level: 4)} public sealed partial class {modelData.ClassName} {{ {modelData.Properties.Select(property => @$" {property.Summary.ToXmlDocumentationSummary(level: 8)} - [global::System.Text.Json.Serialization.JsonPropertyName(""{property.Id}"")] + {jsonSerializer.GeneratePropertyAttribute(property.Id)} public{(property.IsRequired ? " required" : "")} {property.Type} {property.Name} {{ get; set; }}{(property.IsRequired || property.DefaultValue == null ? string.Empty : $" = {property.DefaultValue};")} ").Inject()} {"Additional properties that are not explicitly defined in the schema".ToXmlDocumentationSummary(level: 8)} - [global::System.Text.Json.Serialization.JsonExtensionData] + {jsonSerializer.GenerateExtensionDataAttribute()} public global::System.Collections.Generic.IDictionary AdditionalProperties {{ get; set; }} = new global::System.Collections.Generic.Dictionary(); }}".RemoveBlankLinesWhereOnlyWhitespaces(); } diff --git a/src/libs/OpenApiGenerator.Core/Json/IJsonSerializer.cs b/src/libs/OpenApiGenerator.Core/Json/IJsonSerializer.cs new file mode 100644 index 0000000000..745afbbfe6 --- /dev/null +++ b/src/libs/OpenApiGenerator.Core/Json/IJsonSerializer.cs @@ -0,0 +1,7 @@ +namespace OpenApiGenerator.Core.Json; + +public interface IJsonSerializer +{ + public string GeneratePropertyAttribute(string id); + string GenerateExtensionDataAttribute(); +} \ No newline at end of file diff --git a/src/libs/OpenApiGenerator.Core/Json/JsonSerializationTypeExtensions.cs b/src/libs/OpenApiGenerator.Core/Json/JsonSerializationTypeExtensions.cs new file mode 100644 index 0000000000..ad183f7995 --- /dev/null +++ b/src/libs/OpenApiGenerator.Core/Json/JsonSerializationTypeExtensions.cs @@ -0,0 +1,15 @@ +namespace OpenApiGenerator.Core.Json; + +public static class JsonSerializationTypeExtensions +{ + // Returns the serializer type based on the provided enum value. + public static IJsonSerializer GetSerializer(this JsonSerializerType type) + { + return type switch + { + JsonSerializerType.SystemTextJson => SystemTextJsonSerializer.Instance, + JsonSerializerType.NewtonsoftJson => NewtonsoftJsonSerializer.Instance, + _ => throw new NotSupportedException($"Serializer type {type} is not supported.") + }; + } +} \ No newline at end of file diff --git a/src/libs/OpenApiGenerator.Core/Json/JsonSerializerType.cs b/src/libs/OpenApiGenerator.Core/Json/JsonSerializerType.cs new file mode 100644 index 0000000000..171c62e8c1 --- /dev/null +++ b/src/libs/OpenApiGenerator.Core/Json/JsonSerializerType.cs @@ -0,0 +1,7 @@ +namespace OpenApiGenerator.Core.Json; + +public enum JsonSerializerType +{ + SystemTextJson, + NewtonsoftJson, +} \ No newline at end of file diff --git a/src/libs/OpenApiGenerator.Core/Json/NewtonsoftJsonSerializer.cs b/src/libs/OpenApiGenerator.Core/Json/NewtonsoftJsonSerializer.cs new file mode 100644 index 0000000000..e719936298 --- /dev/null +++ b/src/libs/OpenApiGenerator.Core/Json/NewtonsoftJsonSerializer.cs @@ -0,0 +1,16 @@ +namespace OpenApiGenerator.Core.Json; + +public class NewtonsoftJsonSerializer : IJsonSerializer +{ + public static IJsonSerializer Instance { get; } = new NewtonsoftJsonSerializer(); + + public string GeneratePropertyAttribute(string id) + { + return $"[global::Newtonsoft.Json.JsonProperty(\"{id}\")]"; + } + + public string GenerateExtensionDataAttribute() + { + return "[global::Newtonsoft.Json.JsonExtensionData]"; + } +} \ No newline at end of file diff --git a/src/libs/OpenApiGenerator.Core/Json/SystemTextJsonSerializer.cs b/src/libs/OpenApiGenerator.Core/Json/SystemTextJsonSerializer.cs new file mode 100644 index 0000000000..a55500a36a --- /dev/null +++ b/src/libs/OpenApiGenerator.Core/Json/SystemTextJsonSerializer.cs @@ -0,0 +1,16 @@ +namespace OpenApiGenerator.Core.Json; + +public class SystemTextJsonSerializer : IJsonSerializer +{ + public static IJsonSerializer Instance { get; } = new SystemTextJsonSerializer(); + + public string GeneratePropertyAttribute(string id) + { + return $"[global::System.Text.Json.Serialization.JsonPropertyName(\"{id}\")]"; + } + + public string GenerateExtensionDataAttribute() + { + return "[global::System.Text.Json.Serialization.JsonExtensionData]"; + } +} \ No newline at end of file diff --git a/src/libs/OpenApiGenerator.Core/Models/ModelData.cs b/src/libs/OpenApiGenerator.Core/Models/ModelData.cs index c47489eb1f..9152a9dbe6 100644 --- a/src/libs/OpenApiGenerator.Core/Models/ModelData.cs +++ b/src/libs/OpenApiGenerator.Core/Models/ModelData.cs @@ -1,6 +1,7 @@ using System.Collections.Immutable; using Microsoft.OpenApi.Models; using OpenApiGenerator.Core.Extensions; +using OpenApiGenerator.Core.Json; namespace OpenApiGenerator.Core.Models; @@ -12,6 +13,7 @@ public readonly record struct ModelData( string Namespace, NamingConvention NamingConvention, ModelStyle Style, + JsonSerializerType JsonSerializerType, ImmutableArray Properties, string Summary, ImmutableArray AdditionalModels, @@ -45,6 +47,7 @@ public static ModelData FromKey( Parents: parents.ToImmutableArray(), Namespace: settings.Namespace, NamingConvention: settings.NamingConvention, + JsonSerializerType: settings.JsonSerializerType, Style: settings.ModelStyle, Properties: ImmutableArray.Empty, Summary: string.Empty, @@ -65,6 +68,7 @@ public static ModelData FromSchema( Parents: parents.ToImmutableArray(), Namespace: settings.Namespace, NamingConvention: settings.NamingConvention, + JsonSerializerType: settings.JsonSerializerType, Style: settings.ModelStyle, Properties: ImmutableArray.Empty, Summary: schema.Value.GetSummary(), diff --git a/src/libs/OpenApiGenerator.Core/Models/Settings.cs b/src/libs/OpenApiGenerator.Core/Models/Settings.cs index 5577e68231..c1a3039cb7 100644 --- a/src/libs/OpenApiGenerator.Core/Models/Settings.cs +++ b/src/libs/OpenApiGenerator.Core/Models/Settings.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using OpenApiGenerator.Core.Json; namespace OpenApiGenerator.Core.Models; @@ -7,6 +8,7 @@ public readonly record struct Settings( string Namespace, string ClassName, NamingConvention NamingConvention, + JsonSerializerType JsonSerializerType, ImmutableArray IncludeOperationIds, diff --git a/src/libs/OpenApiGenerator/OpenApiGenerator.props b/src/libs/OpenApiGenerator/OpenApiGenerator.props index 90694b9686..cbd62af94a 100644 --- a/src/libs/OpenApiGenerator/OpenApiGenerator.props +++ b/src/libs/OpenApiGenerator/OpenApiGenerator.props @@ -20,6 +20,8 @@ + + diff --git a/src/libs/OpenApiGenerator/OptionsExtensions.cs b/src/libs/OpenApiGenerator/OptionsExtensions.cs index 5bc8d1f306..3aa414a96f 100644 --- a/src/libs/OpenApiGenerator/OptionsExtensions.cs +++ b/src/libs/OpenApiGenerator/OptionsExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using OpenApiGenerator.Core.Models; using OpenApiGenerator.Core.Extensions; +using OpenApiGenerator.Core.Json; namespace OpenApiGenerator; @@ -30,6 +31,11 @@ public static Settings GetSettings( $"{default(NamingConvention):G}", ignoreCase: true, out var namingConvention) ? namingConvention : default, + JsonSerializerType: Enum.TryParse( + options.GetGlobalOption(nameof(Settings.JsonSerializerType), prefix) ?? + $"{default(JsonSerializerType):G}", + ignoreCase: true, + out var jsonSerializerType) ? jsonSerializerType : default, IncludeOperationIds: (options.GetGlobalOption(nameof(Settings.IncludeOperationIds), prefix)?.Split(';') ?? Array.Empty()).ToImmutableArray(), diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponse.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponse.g.verified.cs index 19679343ee..8a0ccd364a 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponse.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponse.g.verified.cs @@ -13,7 +13,7 @@ public sealed partial class CreateModelResponse /// Status creating the model /// [global::System.Text.Json.Serialization.JsonPropertyName("status")] - public CreateModelResponseStatus? Status { get; set; } + public string? Status { get; set; } /// /// Additional properties that are not explicitly defined in the schema diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponseStatus.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponseStatus.g.verified.cs index d49c59a40c..72dee32734 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponseStatus.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.CreateModelResponseStatus.g.verified.cs @@ -7,23 +7,19 @@ namespace G /// /// Status creating the model /// - [global::System.Runtime.Serialization.DataContract] - public enum CreateModelResponseStatus + public abstract class CreateModelResponseStatus { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="creating system layer")] - CreatingSystemLayer, + public const string CreatingSystemLayer = "creating system layer"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="parsing modelfile")] - ParsingModelfile, + public const string ParsingModelfile = "parsing modelfile"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="success")] - Success, + public const string Success = "success"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequest.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequest.g.verified.cs index b8d70461ac..cfa0d6314d 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequest.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequest.g.verified.cs @@ -29,7 +29,7 @@ public sealed partial class GenerateChatCompletionRequest /// Note: it's important to instruct the model to use JSON in the prompt. Otherwise, the model may generate large amounts whitespace. /// [global::System.Text.Json.Serialization.JsonPropertyName("format")] - public GenerateChatCompletionRequestFormat? Format { get; set; } + public string? Format { get; set; } /// /// Additional model parameters listed in the documentation for the Modelfile such as `temperature`. diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequestFormat.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequestFormat.g.verified.cs index 5caa80ec18..c30b96e0d9 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequestFormat.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateChatCompletionRequestFormat.g.verified.cs @@ -9,13 +9,11 @@ namespace G /// Enable JSON mode by setting the format parameter to json. This will structure the response as valid JSON. /// Note: it's important to instruct the model to use JSON in the prompt. Otherwise, the model may generate large amounts whitespace. /// - [global::System.Runtime.Serialization.DataContract] - public enum GenerateChatCompletionRequestFormat + public abstract class GenerateChatCompletionRequestFormat { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="json")] - Json, + public const string Json = "json"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequest.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequest.g.verified.cs index c67c71c670..53d8aeb7d4 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequest.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequest.g.verified.cs @@ -60,7 +60,7 @@ public sealed partial class GenerateCompletionRequest /// Note: it's important to instruct the model to use JSON in the prompt. Otherwise, the model may generate large amounts whitespace. /// [global::System.Text.Json.Serialization.JsonPropertyName("format")] - public GenerateCompletionRequestFormat? Format { get; set; } + public string? Format { get; set; } /// /// If `true` no formatting will be applied to the prompt and no context will be returned. diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequestFormat.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequestFormat.g.verified.cs index 59a27b0291..0bb67917ef 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequestFormat.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.GenerateCompletionRequestFormat.g.verified.cs @@ -9,13 +9,11 @@ namespace G /// Enable JSON mode by setting the format parameter to json. This will structure the response as valid JSON. /// Note: it's important to instruct the model to use JSON in the prompt. Otherwise, the model may generate large amounts whitespace. /// - [global::System.Runtime.Serialization.DataContract] - public enum GenerateCompletionRequestFormat + public abstract class GenerateCompletionRequestFormat { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="json")] - Json, + public const string Json = "json"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.Message.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.Message.g.verified.cs index 0cdc4d3717..dc33b93ea5 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.Message.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.Message.g.verified.cs @@ -13,7 +13,7 @@ public sealed partial class Message /// The role of the message /// [global::System.Text.Json.Serialization.JsonPropertyName("role")] - public required MessageRole Role { get; set; } + public required string Role { get; set; } /// /// The content of the message diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.MessageRole.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.MessageRole.g.verified.cs index 76bf0b7247..53cab021e8 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.MessageRole.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.MessageRole.g.verified.cs @@ -7,23 +7,19 @@ namespace G /// /// The role of the message /// - [global::System.Runtime.Serialization.DataContract] - public enum MessageRole + public abstract class MessageRole { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="system")] - System, + public const string System = "system"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="user")] - User, + public const string User = "user"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="assistant")] - Assistant, + public const string Assistant = "assistant"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponse.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponse.g.verified.cs index ae0a02c13f..dae3c60324 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponse.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponse.g.verified.cs @@ -16,7 +16,7 @@ public sealed partial class PullModelResponse ///
Example: pulling manifest ///
[global::System.Text.Json.Serialization.JsonPropertyName("status")] - public PullModelResponseStatus? Status { get; set; } + public string? Status { get; set; } /// /// The model's digest. diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponseStatus.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponseStatus.g.verified.cs index ce34fea000..5bfa22a7f6 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponseStatus.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PullModelResponseStatus.g.verified.cs @@ -8,38 +8,31 @@ namespace G /// Status pulling the model. ///
Example: pulling manifest ///
- [global::System.Runtime.Serialization.DataContract] - public enum PullModelResponseStatus + public abstract class PullModelResponseStatus { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="pulling manifest")] - PullingManifest, + public const string PullingManifest = "pulling manifest"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="downloading digestname")] - DownloadingDigestname, + public const string DownloadingDigestname = "downloading digestname"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="verifying sha256 digest")] - VerifyingSha256Digest, + public const string VerifyingSha256Digest = "verifying sha256 digest"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="writing manifest")] - WritingManifest, + public const string WritingManifest = "writing manifest"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="removing any unused layers")] - RemovingAnyUnusedLayers, + public const string RemovingAnyUnusedLayers = "removing any unused layers"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="success")] - Success, + public const string Success = "success"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponse.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponse.g.verified.cs index ced3341955..00e6f2d7c6 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponse.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponse.g.verified.cs @@ -13,7 +13,7 @@ public sealed partial class PushModelResponse /// Status pushing the model. /// [global::System.Text.Json.Serialization.JsonPropertyName("status")] - public PushModelResponseStatus? Status { get; set; } + public string? Status { get; set; } /// /// the model's digest diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponseStatus.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponseStatus.g.verified.cs index efaed21f2c..5e34fd2cfa 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponseStatus.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ollama/_#G.Models.PushModelResponseStatus.g.verified.cs @@ -7,28 +7,23 @@ namespace G /// /// Status pushing the model. /// - [global::System.Runtime.Serialization.DataContract] - public enum PushModelResponseStatus + public abstract class PushModelResponseStatus { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="retrieving manifest")] - RetrievingManifest, + public const string RetrievingManifest = "retrieving manifest"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="starting upload")] - StartingUpload, + public const string StartingUpload = "starting upload"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="pushing manifest")] - PushingManifest, + public const string PushingManifest = "pushing manifest"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="success")] - Success, + public const string Success = "success"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.CreateCompletionRequestModel.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.CreateCompletionRequestModel.g.verified.cs index cb41a5e36d..49ef94154b 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.CreateCompletionRequestModel.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.CreateCompletionRequestModel.g.verified.cs @@ -7,58 +7,47 @@ namespace G /// /// /// - [global::System.Runtime.Serialization.DataContract] - public enum CreateCompletionRequestModel + public abstract class CreateCompletionRequestModel { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="babbage-002")] - Babbage002, + public const string Babbage002 = "babbage-002"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="davinci-002")] - Davinci002, + public const string Davinci002 = "davinci-002"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="gpt-3.5-turbo-instruct")] - Gpt35TurboInstruct, + public const string Gpt35TurboInstruct = "gpt-3.5-turbo-instruct"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="text-davinci-003")] - TextDavinci003, + public const string TextDavinci003 = "text-davinci-003"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="text-davinci-002")] - TextDavinci002, + public const string TextDavinci002 = "text-davinci-002"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="text-davinci-001")] - TextDavinci001, + public const string TextDavinci001 = "text-davinci-001"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="code-davinci-002")] - CodeDavinci002, + public const string CodeDavinci002 = "code-davinci-002"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="text-curie-001")] - TextCurie001, + public const string TextCurie001 = "text-curie-001"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="text-babbage-001")] - TextBabbage001, + public const string TextBabbage001 = "text-babbage-001"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="text-ada-001")] - TextAda001, + public const string TextAda001 = "text-ada-001"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponse.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponse.g.verified.cs index ca3060c96a..9681c95c7b 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponse.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponse.g.verified.cs @@ -13,7 +13,7 @@ public sealed partial class ListModelsResponse /// /// [global::System.Text.Json.Serialization.JsonPropertyName("object")] - public required ListModelsResponseObject Object { get; set; } + public required string Object { get; set; } /// /// diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponseObject.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponseObject.g.verified.cs index ae30f0db96..6c675153c6 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponseObject.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ListModelsResponseObject.g.verified.cs @@ -7,13 +7,11 @@ namespace G /// /// /// - [global::System.Runtime.Serialization.DataContract] - public enum ListModelsResponseObject + public abstract class ListModelsResponseObject { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="list")] - List, + public const string List = "list"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.Model.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.Model.g.verified.cs index 7a2815ba41..c7dfca9540 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.Model.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.Model.g.verified.cs @@ -25,7 +25,7 @@ public sealed partial class Model /// The object type, which is always "model". /// [global::System.Text.Json.Serialization.JsonPropertyName("object")] - public required ModelObject Object { get; set; } + public required string Object { get; set; } /// /// The organization that owns the model. diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ModelObject.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ModelObject.g.verified.cs index 5ff300b6aa..bfcb15115b 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ModelObject.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi/_#G.Models.ModelObject.g.verified.cs @@ -7,13 +7,11 @@ namespace G /// /// The object type, which is always "model". /// - [global::System.Runtime.Serialization.DataContract] - public enum ModelObject + public abstract class ModelObject { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="model")] - Model, + public const string Model = "model"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponse.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponse.g.verified.cs index e82bf05d49..0654bd8f65 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponse.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponse.g.verified.cs @@ -44,7 +44,7 @@ public sealed partial class CreateCompletionResponse /// The object type, which is always "text_completion" /// [global::System.Text.Json.Serialization.JsonPropertyName("object")] - public required CreateCompletionResponseObject Object { get; set; } + public required string Object { get; set; } /// /// Usage statistics for the completion request. diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoices.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoices.g.verified.cs index 6a90f164a8..407e9c6be7 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoices.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoices.g.verified.cs @@ -15,7 +15,7 @@ public sealed partial class CreateCompletionResponseChoices /// or `content_filter` if content was omitted due to a flag from our content filters. /// [global::System.Text.Json.Serialization.JsonPropertyName("finish_reason")] - public required CreateCompletionResponseChoicesFinishReason FinishReason { get; set; } + public required string FinishReason { get; set; } /// /// diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoicesFinishReason.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoicesFinishReason.g.verified.cs index 9413e0f121..ce59b093f0 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoicesFinishReason.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseChoicesFinishReason.g.verified.cs @@ -9,23 +9,19 @@ namespace G /// `length` if the maximum number of tokens specified in the request was reached, /// or `content_filter` if content was omitted due to a flag from our content filters. /// - [global::System.Runtime.Serialization.DataContract] - public enum CreateCompletionResponseChoicesFinishReason + public abstract class CreateCompletionResponseChoicesFinishReason { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="stop")] - Stop, + public const string Stop = "stop"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="length")] - Length, + public const string Length = "length"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="content_filter")] - ContentFilter, + public const string ContentFilter = "content_filter"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseObject.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseObject.g.verified.cs index e8add15a88..38545cd89b 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseObject.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/OpenAi_CreateCompletionResponse/_#G.Models.CreateCompletionResponseObject.g.verified.cs @@ -7,13 +7,11 @@ namespace G /// /// The object type, which is always "text_completion" /// - [global::System.Runtime.Serialization.DataContract] - public enum CreateCompletionResponseObject + public abstract class CreateCompletionResponseObject { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="text_completion")] - TextCompletion, + public const string TextCompletion = "text_completion"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponse.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponse.g.verified.cs index 878b1973d5..182d42a73a 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponse.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponse.g.verified.cs @@ -61,7 +61,7 @@ public sealed partial class AsnResponse ///
Example: isp /// [global::System.Text.Json.Serialization.JsonPropertyName("type")] - public required AsnResponseType Type { get; set; } + public required string Type { get; set; } /// /// diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponseType.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponseType.g.verified.cs index e7f17a6e17..eed9adefd9 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponseType.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.AsnResponseType.g.verified.cs @@ -7,33 +7,27 @@ namespace G /// ///
Example: isp ///
- [global::System.Runtime.Serialization.DataContract] - public enum AsnResponseType + public abstract class AsnResponseType { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="isp")] - Isp, + public const string Isp = "isp"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="business")] - Business, + public const string Business = "business"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="education")] - Education, + public const string Education = "education"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="hosting")] - Hosting, + public const string Hosting = "hosting"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="inactive")] - Inactive, + public const string Inactive = "inactive"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.Company.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.Company.g.verified.cs index d122707d18..17230f3542 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.Company.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.Company.g.verified.cs @@ -25,7 +25,7 @@ public sealed partial class Company ///
Example: isp ///
[global::System.Text.Json.Serialization.JsonPropertyName("type")] - public required CompanyType Type { get; set; } + public required string Type { get; set; } /// /// Additional properties that are not explicitly defined in the schema diff --git a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.CompanyType.g.verified.cs b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.CompanyType.g.verified.cs index f99e898e4c..d58f93a61e 100644 --- a/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.CompanyType.g.verified.cs +++ b/src/tests/OpenApiGenerator.SnapshotTests/Snapshots/YamlWithLocalFile/_#G.Models.CompanyType.g.verified.cs @@ -7,28 +7,23 @@ namespace G /// ///
Example: isp ///
- [global::System.Runtime.Serialization.DataContract] - public enum CompanyType + public abstract class CompanyType { /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="isp")] - Isp, + public const string Isp = "isp"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="business")] - Business, + public const string Business = "business"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="education")] - Education, + public const string Education = "education"; /// /// /// - [global::System.Runtime.Serialization.EnumMember(Value="hosting")] - Hosting, + public const string Hosting = "hosting"; } } \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.UnitTests/ModelTests.cs b/src/tests/OpenApiGenerator.UnitTests/ModelTests.cs index 4de8536a11..b4fbd22bd6 100644 --- a/src/tests/OpenApiGenerator.UnitTests/ModelTests.cs +++ b/src/tests/OpenApiGenerator.UnitTests/ModelTests.cs @@ -14,6 +14,7 @@ public class ModelTests : Namespace: "G", ClassName: "Api", NamingConvention: default, + JsonSerializerType: default, IncludeOperationIds: [], GenerateModels: true, ModelStyle: default, diff --git a/src/tests/OpenApiGenerator.UnitTests/Snapshots/Ollama/_.verified.txt b/src/tests/OpenApiGenerator.UnitTests/Snapshots/Ollama/_.verified.txt index 133d72d725..fcc3f581b0 100644 --- a/src/tests/OpenApiGenerator.UnitTests/Snapshots/Ollama/_.verified.txt +++ b/src/tests/OpenApiGenerator.UnitTests/Snapshots/Ollama/_.verified.txt @@ -64,7 +64,7 @@ The prompt to generate a response. { Id: format, Name: Format, - Type: GenerateCompletionRequestFormat?, + Type: string?, IsRequired: false, Summary: The format to return a response in. Currently the only accepted value is json. @@ -624,7 +624,7 @@ Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` a { Id: format, Name: Format, - Type: GenerateChatCompletionRequestFormat?, + Type: string?, IsRequired: false, Summary: The format to return a response in. Currently the only accepted value is json. @@ -819,7 +819,7 @@ Time in nanoseconds spent generating the response. { Id: role, Name: Role, - Type: MessageRole, + Type: string, IsRequired: true, Summary: The role of the message }, @@ -1008,7 +1008,7 @@ If `false` the response will be returned as a single response object, otherwise { Id: status, Name: Status, - Type: CreateModelResponseStatus?, + Type: string?, IsRequired: false, Summary: Status creating the model } @@ -1337,7 +1337,7 @@ If `false` the response will be returned as a single response object, otherwise { Id: status, Name: Status, - Type: PullModelResponseStatus?, + Type: string?, IsRequired: false, Summary: Status pulling the model. @@ -1518,7 +1518,7 @@ If `false` the response will be returned as a single response object, otherwise { Id: status, Name: Status, - Type: PushModelResponseStatus?, + Type: string?, IsRequired: false, Summary: Status pushing the model. }, diff --git a/src/tests/OpenApiGenerator.UnitTests/Snapshots/OpenAi/_.verified.txt b/src/tests/OpenApiGenerator.UnitTests/Snapshots/OpenAi/_.verified.txt index 96b14cf978..17dcd976c8 100644 --- a/src/tests/OpenApiGenerator.UnitTests/Snapshots/OpenAi/_.verified.txt +++ b/src/tests/OpenApiGenerator.UnitTests/Snapshots/OpenAi/_.verified.txt @@ -73,7 +73,7 @@ { Id: object, Name: Object, - Type: ListModelsResponseObject, + Type: string, IsRequired: true, Summary: }, @@ -530,7 +530,7 @@ Can be used in conjunction with the `seed` request parameter to understand when { Id: object, Name: Object, - Type: CreateCompletionResponseObject, + Type: string, IsRequired: true, Summary: The object type, which is always "text_completion" }, @@ -561,7 +561,7 @@ Represents a completion response from the API. Note: both the streamed and non-s { Id: finish_reason, Name: FinishReason, - Type: CreateCompletionResponseChoicesFinishReason, + Type: string, IsRequired: true, Summary: The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, @@ -743,7 +743,7 @@ or `content_filter` if content was omitted due to a flag from our content filter { Id: type, Name: Type, - Type: ChatCompletionRequestMessageContentPartImageType, + Type: string, IsRequired: true, Summary: The type of the content part. }, @@ -779,7 +779,7 @@ or `content_filter` if content was omitted due to a flag from our content filter { Id: detail, Name: Detail, - Type: ChatCompletionRequestMessageContentPartImageImageUrlDetail?, + Type: string?, IsRequired: false, DefaultValue: auto, Summary: @@ -866,7 +866,7 @@ Specifies the detail level of the image. Learn more in the [Vision guide](/docs/ { Id: type, Name: Type, - Type: ChatCompletionRequestMessageContentPartTextType, + Type: string, IsRequired: true, Summary: The type of the content part. }, @@ -939,7 +939,7 @@ Specifies the detail level of the image. Learn more in the [Vision guide](/docs/ { Id: role, Name: Role, - Type: ChatCompletionRequestSystemMessageRole, + Type: string, IsRequired: true, Summary: The role of the messages author, in this case `system`. }, @@ -1000,7 +1000,7 @@ The contents of the user message. { Id: role, Name: Role, - Type: ChatCompletionRequestUserMessageRole, + Type: string, IsRequired: true, Summary: The role of the messages author, in this case `user`. }, @@ -1061,7 +1061,7 @@ The contents of the assistant message. Required unless `tool_calls` or `function { Id: role, Name: Role, - Type: ChatCompletionRequestAssistantMessageRole, + Type: string, IsRequired: true, Summary: The role of the messages author, in this case `assistant`. }, @@ -1156,7 +1156,7 @@ The contents of the assistant message. Required unless `tool_calls` or `function { Id: role, Name: Role, - Type: ChatCompletionRequestToolMessageRole, + Type: string, IsRequired: true, Summary: The role of the messages author, in this case `tool`. }, @@ -1215,7 +1215,7 @@ The contents of the assistant message. Required unless `tool_calls` or `function { Id: role, Name: Role, - Type: ChatCompletionRequestFunctionMessageRole, + Type: string, IsRequired: true, Summary: The role of the messages author, in this case `function`. }, @@ -1354,7 +1354,7 @@ Specifying a particular function via `{"name": "my_function"}` forces the model { Id: type, Name: Type, - Type: ChatCompletionToolType, + Type: string, IsRequired: true, Summary: The type of the tool. Currently, only `function` is supported. }, @@ -1466,7 +1466,7 @@ Specifying a particular function via `{"type: "function", "function": {"name": " { Id: type, Name: Type, - Type: ChatCompletionNamedToolChoiceType, + Type: string, IsRequired: true, Summary: The type of the tool. Currently, only `function` is supported. }, @@ -1561,7 +1561,7 @@ Specifying a particular function via `{"type: "function", "function": {"name": " { Id: type, Name: Type, - Type: ChatCompletionMessageToolCallType, + Type: string, IsRequired: true, Summary: The type of the tool. Currently, only `function` is supported. }, @@ -1656,7 +1656,7 @@ Specifying a particular function via `{"type: "function", "function": {"name": " { Id: type, Name: Type, - Type: ChatCompletionMessageToolCallChunkType?, + Type: string?, IsRequired: false, Summary: The type of the tool. Currently, only `function` is supported. }, @@ -1765,7 +1765,7 @@ Specifying a particular function via `{"type: "function", "function": {"name": " { Id: role, Name: Role, - Type: ChatCompletionResponseMessageRole, + Type: string, IsRequired: true, Summary: The role of the author of this message. }, @@ -1867,7 +1867,7 @@ Specifying a particular function via `{"type: "function", "function": {"name": " { Id: role, Name: Role, - Type: ChatCompletionStreamResponseDeltaRole?, + Type: string?, IsRequired: false, Summary: The role of the author of this message. } @@ -2222,7 +2222,7 @@ Accepts a JSON object that maps tokens (specified by their token ID in the token { Id: type, Name: Type, - Type: CreateChatCompletionRequestResponseFormatType?, + Type: string?, IsRequired: false, DefaultValue: text, Summary: @@ -2504,7 +2504,7 @@ Can be used in conjunction with the `seed` request parameter to understand when { Id: object, Name: Object, - Type: CreateChatCompletionResponseObject, + Type: string, IsRequired: true, Summary: The object type, which is always `chat.completion`. }, @@ -2533,7 +2533,7 @@ Can be used in conjunction with the `seed` request parameter to understand when { Id: finish_reason, Name: FinishReason, - Type: CreateChatCompletionResponseChoicesFinishReason, + Type: string, IsRequired: true, Summary: The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, @@ -2721,7 +2721,7 @@ Can be used in conjunction with the `seed` request parameter to understand when { Id: object, Name: Object, - Type: CreateChatCompletionFunctionResponseObject, + Type: string, IsRequired: true, Summary: The object type, which is always `chat.completion`. }, @@ -2750,7 +2750,7 @@ Can be used in conjunction with the `seed` request parameter to understand when { Id: finish_reason, Name: FinishReason, - Type: CreateChatCompletionFunctionResponseChoicesFinishReason, + Type: string, IsRequired: true, Summary: The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. @@ -2950,7 +2950,7 @@ The reason the model stopped generating tokens. This will be `stop` if the model { Id: object, Name: Object, - Type: ListPaginatedFineTuningJobsResponseObject, + Type: string, IsRequired: true, Summary: } @@ -3033,7 +3033,7 @@ Can be used in conjunction with the `seed` request parameter to understand when { Id: object, Name: Object, - Type: CreateChatCompletionStreamResponseObject, + Type: string, IsRequired: true, Summary: The object type, which is always `chat.completion.chunk`. } @@ -3069,7 +3069,7 @@ Can be used in conjunction with the `seed` request parameter to understand when { Id: finish_reason, Name: FinishReason, - Type: CreateChatCompletionStreamResponseChoicesFinishReason?, + Type: string?, IsRequired: true, Summary: The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, @@ -3338,7 +3338,7 @@ We generally recommend altering this or `temperature` but not both. { Id: object, Name: Object, - Type: CreateEditResponseObject, + Type: string, IsRequired: true, Summary: The object type, which is always `edit`. }, @@ -3374,7 +3374,7 @@ We generally recommend altering this or `temperature` but not both. { Id: finish_reason, Name: FinishReason, - Type: CreateEditResponseChoicesFinishReason, + Type: string, IsRequired: true, Summary: The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, @@ -3502,7 +3502,7 @@ The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only { Id: quality, Name: Quality, - Type: CreateImageRequestQuality?, + Type: string?, IsRequired: false, DefaultValue: standard, Summary: @@ -3513,7 +3513,7 @@ The quality of the image that will be generated. `hd` creates images with finer { Id: response_format, Name: ResponseFormat, - Type: CreateImageRequestResponseFormat?, + Type: string?, IsRequired: false, DefaultValue: url, Summary: @@ -3524,7 +3524,7 @@ The format in which the generated images are returned. Must be one of `url` or ` { Id: size, Name: Size, - Type: CreateImageRequestSize?, + Type: string?, IsRequired: false, DefaultValue: 1024x1024, Summary: @@ -3535,7 +3535,7 @@ The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x { Id: style, Name: Style, - Type: CreateImageRequestStyle?, + Type: string?, IsRequired: false, DefaultValue: vivid, Summary: @@ -3864,7 +3864,7 @@ The number of images to generate. Must be between 1 and 10. { Id: size, Name: Size, - Type: CreateImageEditRequestSize?, + Type: string?, IsRequired: false, DefaultValue: 1024x1024, Summary: @@ -3875,7 +3875,7 @@ The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x { Id: response_format, Name: ResponseFormat, - Type: CreateImageEditRequestResponseFormat?, + Type: string?, IsRequired: false, DefaultValue: url, Summary: @@ -4036,7 +4036,7 @@ The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only { Id: response_format, Name: ResponseFormat, - Type: CreateImageVariationRequestResponseFormat?, + Type: string?, IsRequired: false, DefaultValue: url, Summary: @@ -4047,7 +4047,7 @@ The format in which the generated images are returned. Must be one of `url` or ` { Id: size, Name: Size, - Type: CreateImageVariationRequestSize?, + Type: string?, IsRequired: false, DefaultValue: 1024x1024, Summary: @@ -4508,7 +4508,7 @@ The default is `text-moderation-latest` which will be automatically upgraded ove { Id: object, Name: Object, - Type: ListFilesResponseObject, + Type: string, IsRequired: true, Summary: } @@ -4562,7 +4562,7 @@ The File object (not file name) to be uploaded. { Id: purpose, Name: Purpose, - Type: CreateFileRequestPurpose, + Type: string, IsRequired: true, Summary: The intended purpose of the uploaded file. @@ -4629,7 +4629,7 @@ Use "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tuning) and "assistan { Id: object, Name: Object, - Type: DeleteFileResponseObject, + Type: string, IsRequired: true, Summary: }, @@ -4925,7 +4925,7 @@ through the training dataset. { Id: object, Name: Object, - Type: ListFineTuningJobEventsResponseObject, + Type: string, IsRequired: true, Summary: } @@ -5272,7 +5272,7 @@ full cycle through the training dataset. { Id: object, Name: Object, - Type: ListFineTunesResponseObject, + Type: string, IsRequired: true, Summary: } @@ -5324,7 +5324,7 @@ full cycle through the training dataset. { Id: object, Name: Object, - Type: ListFineTuneEventsResponseObject, + Type: string, IsRequired: true, Summary: } @@ -5389,7 +5389,7 @@ ID of the model to use. You can use the [List models](/docs/api-reference/models { Id: encoding_format, Name: EncodingFormat, - Type: CreateEmbeddingRequestEncodingFormat?, + Type: string?, IsRequired: false, DefaultValue: float, Summary: @@ -5495,7 +5495,7 @@ The format to return the embeddings in. Can be either `float` or [`base64`](http { Id: object, Name: Object, - Type: CreateEmbeddingResponseObject, + Type: string, IsRequired: true, Summary: The object type, which is always "list". }, @@ -5613,7 +5613,7 @@ An optional text to guide the model's style or continue a previous audio segment { Id: response_format, Name: ResponseFormat, - Type: CreateTranscriptionRequestResponseFormat?, + Type: string?, IsRequired: false, DefaultValue: json, Summary: @@ -5875,14 +5875,14 @@ One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd` { Id: voice, Name: Voice, - Type: CreateSpeechRequestVoice, + Type: string, IsRequired: true, Summary: The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options). }, { Id: response_format, Name: ResponseFormat, - Type: CreateSpeechRequestResponseFormat?, + Type: string?, IsRequired: false, DefaultValue: mp3, Summary: @@ -6065,7 +6065,7 @@ The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`. { Id: object, Name: Object, - Type: ModelObject, + Type: string, IsRequired: true, Summary: The object type, which is always "model". }, @@ -6145,21 +6145,21 @@ The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`. { Id: object, Name: Object, - Type: OpenAIFileObject, + Type: string, IsRequired: true, Summary: The object type, which is always `file`. }, { Id: purpose, Name: Purpose, - Type: OpenAIFilePurpose, + Type: string, IsRequired: true, Summary: The intended purpose of the file. Supported values are `fine-tune`, `fine-tune-results`, `assistants`, and `assistants_output`. }, { Id: status, Name: Status, - Type: OpenAIFileStatus, + Type: string, IsRequired: true, Summary: Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`. }, @@ -6308,7 +6308,7 @@ The embedding vector, which is a list of floats. The length of vector depends on { Id: object, Name: Object, - Type: EmbeddingObject, + Type: string, IsRequired: true, Summary: The object type, which is always "embedding". } @@ -6404,7 +6404,7 @@ Represents an embedding vector returned by embedding endpoint. { Id: object, Name: Object, - Type: FineTuningJobObject, + Type: string, IsRequired: true, Summary: The object type, which is always "fine_tuning.job". }, @@ -6425,7 +6425,7 @@ Represents an embedding vector returned by embedding endpoint. { Id: status, Name: Status, - Type: FineTuningJobStatus, + Type: string, IsRequired: true, Summary: The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. }, @@ -6650,7 +6650,7 @@ The number of epochs to train the model for. An epoch refers to one full cycle t { Id: level, Name: Level, - Type: FineTuningJobEventLevel, + Type: string, IsRequired: true, Summary: }, @@ -6664,7 +6664,7 @@ The number of epochs to train the model for. An epoch refers to one full cycle t { Id: object, Name: Object, - Type: FineTuningJobEventObject, + Type: string, IsRequired: true, Summary: } @@ -6788,7 +6788,7 @@ The number of epochs to train the model for. An epoch refers to one full cycle t { Id: object, Name: Object, - Type: FineTuneObject, + Type: string, IsRequired: true, Summary: The object type, which is always "fine-tune". }, @@ -6978,7 +6978,7 @@ The weight to use for loss on the prompt tokens. { Id: object, Name: Object, - Type: FineTuneEventObject, + Type: string, IsRequired: true, Summary: } @@ -7066,7 +7066,7 @@ The weight to use for loss on the prompt tokens. { Id: object, Name: Object, - Type: AssistantObjectObject, + Type: string, IsRequired: true, Summary: The object type, which is always `assistant`. }, @@ -7411,7 +7411,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: object, Name: Object, - Type: DeleteAssistantResponseObject, + Type: string, IsRequired: true, Summary: } @@ -7510,7 +7510,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: AssistantToolsCodeType, + Type: string, IsRequired: true, Summary: The type of tool being defined: `code_interpreter` } @@ -7555,7 +7555,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: AssistantToolsRetrievalType, + Type: string, IsRequired: true, Summary: The type of tool being defined: `retrieval` } @@ -7600,7 +7600,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: AssistantToolsFunctionType, + Type: string, IsRequired: true, Summary: The type of tool being defined: `function` }, @@ -7659,7 +7659,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: object, Name: Object, - Type: RunObjectObject, + Type: string, IsRequired: true, Summary: The object type, which is always `thread.run`. }, @@ -7687,7 +7687,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: status, Name: Status, - Type: RunObjectStatus, + Type: string, IsRequired: true, Summary: The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, or `expired`. }, @@ -7801,7 +7801,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: RunObjectRequiredActionType, + Type: string, IsRequired: true, Summary: For now, this is always `submit_tool_outputs`. }, @@ -7875,7 +7875,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: code, Name: Code, - Type: RunObjectLastErrorCode, + Type: string, IsRequired: true, Summary: One of `server_error` or `rate_limit_exceeded`. }, @@ -8272,7 +8272,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: RunToolCallObjectType, + Type: string, IsRequired: true, Summary: The type of tool call the output is required for. For now, this is always `function`. }, @@ -8435,7 +8435,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: object, Name: Object, - Type: ThreadObjectObject, + Type: string, IsRequired: true, Summary: The object type, which is always `thread`. }, @@ -8613,7 +8613,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: object, Name: Object, - Type: DeleteThreadResponseObject, + Type: string, IsRequired: true, Summary: } @@ -8719,7 +8719,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: object, Name: Object, - Type: MessageObjectObject, + Type: string, IsRequired: true, Summary: The object type, which is always `thread.message`. }, @@ -8740,7 +8740,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: role, Name: Role, - Type: MessageObjectRole, + Type: string, IsRequired: true, Summary: The entity that produced the message. One of `user` or `assistant`. }, @@ -8871,7 +8871,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: role, Name: Role, - Type: CreateMessageRequestRole, + Type: string, IsRequired: true, Summary: The role of the entity that is creating the message. Currently only `user` is supported. }, @@ -9012,7 +9012,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: object, Name: Object, - Type: DeleteMessageResponseObject, + Type: string, IsRequired: true, Summary: } @@ -9111,7 +9111,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: MessageContentImageFileObjectType, + Type: string, IsRequired: true, Summary: Always `image_file`. }, @@ -9185,7 +9185,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: MessageContentTextObjectType, + Type: string, IsRequired: true, Summary: Always `text`. }, @@ -9266,7 +9266,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: MessageContentTextAnnotationsFileCitationObjectType, + Type: string, IsRequired: true, Summary: Always `file_citation`. }, @@ -9368,7 +9368,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: MessageContentTextAnnotationsFilePathObjectType, + Type: string, IsRequired: true, Summary: Always `file_path`. }, @@ -9470,7 +9470,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: object, Name: Object, - Type: RunStepObjectObject, + Type: string, IsRequired: true, Summary: The object type, which is always `thread.run.step`. }, @@ -9505,14 +9505,14 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: RunStepObjectType, + Type: string, IsRequired: true, Summary: The type of run step, which can be either `message_creation` or `tool_calls`. }, { Id: status, Name: Status, - Type: RunStepObjectStatus, + Type: string, IsRequired: true, Summary: The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. }, @@ -9601,7 +9601,7 @@ Represents a step in execution of a run. { Id: code, Name: Code, - Type: RunStepObjectLastErrorCode, + Type: string, IsRequired: true, Summary: One of `server_error` or `rate_limit_exceeded`. }, @@ -9834,7 +9834,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: RunStepDetailsMessageCreationObjectType, + Type: string, IsRequired: true, Summary: Always `message_creation`. }, @@ -9908,7 +9908,7 @@ Set of 16 key-value pairs that can be attached to an object. This can be useful { Id: type, Name: Type, - Type: RunStepDetailsToolCallsObjectType, + Type: string, IsRequired: true, Summary: Always `tool_calls`. }, @@ -9983,7 +9983,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: type, Name: Type, - Type: RunStepDetailsToolCallsCodeObjectType, + Type: string, IsRequired: true, Summary: The type of tool call. This is always going to be `code_interpreter` for this type of tool call. }, @@ -10078,7 +10078,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: type, Name: Type, - Type: RunStepDetailsToolCallsCodeOutputLogsObjectType, + Type: string, IsRequired: true, Summary: Always `logs`. }, @@ -10130,7 +10130,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: type, Name: Type, - Type: RunStepDetailsToolCallsCodeOutputImageObjectType, + Type: string, IsRequired: true, Summary: Always `image`. }, @@ -10211,7 +10211,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: type, Name: Type, - Type: RunStepDetailsToolCallsRetrievalObjectType, + Type: string, IsRequired: true, Summary: The type of tool call. This is always going to be `retrieval` for this type of tool call. }, @@ -10284,7 +10284,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: type, Name: Type, - Type: RunStepDetailsToolCallsFunctionObjectType, + Type: string, IsRequired: true, Summary: The type of tool call. This is always going to be `function` for this type of tool call. }, @@ -10379,7 +10379,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: object, Name: Object, - Type: AssistantFileObjectObject, + Type: string, IsRequired: true, Summary: The object type, which is always `assistant.file`. }, @@ -10474,7 +10474,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: object, Name: Object, - Type: DeleteAssistantFileResponseObject, + Type: string, IsRequired: true, Summary: } @@ -10580,7 +10580,7 @@ An array of tool calls the run step was involved in. These can be associated wit { Id: object, Name: Object, - Type: MessageFileObjectObject, + Type: string, IsRequired: true, Summary: The object type, which is always `thread.message.file`. },