-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'aliencube:main' into feature/22-request-payload-definition
- Loading branch information
Showing
61 changed files
with
3,997 additions
and
177 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
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
17 changes: 17 additions & 0 deletions
17
src/AzureOpenAIProxy.ApiApp/Configurations/OpenApiSettings.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,17 @@ | ||
namespace AzureOpenAIProxy.ApiApp.Configurations; | ||
|
||
/// <summary> | ||
/// This represents the settings entity for Open API. | ||
/// </summary> | ||
public class OpenApiSettings | ||
{ | ||
/// <summary> | ||
/// Gets the name of the configuration settings. | ||
/// </summary> | ||
public const string Name = "OpenApi"; | ||
|
||
/// <summary> | ||
/// Gets or sets the Open API Doc version. | ||
/// </summary> | ||
public string? DocVersion { get; set; } = string.Empty; | ||
} |
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
72 changes: 72 additions & 0 deletions
72
src/AzureOpenAIProxy.ApiApp/Converters/EnumMemberConverter.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,72 @@ | ||
using System.Runtime.Serialization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace AzureOpenAIProxy.ApiApp.Converters; | ||
|
||
/// <summary> | ||
/// This represents the converter entity for <see cref="EnumMemberAttribute"/>. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the enum to be converted.</typeparam> | ||
public class EnumMemberConverter<T> : JsonConverter<T> where T : Enum | ||
{ | ||
/// <inheritdoc /> | ||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var enumText = reader.GetString(); | ||
|
||
if (enumText == null) | ||
{ | ||
throw new JsonException($"Unable to convert null to Enum \"{typeToConvert}\"."); | ||
} | ||
|
||
foreach (var field in typeToConvert.GetFields()) | ||
{ | ||
var attribute = Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)) as EnumMemberAttribute; | ||
|
||
if (attribute != null && attribute.Value == enumText) | ||
{ | ||
var value = field.GetValue(null); | ||
if (value != null) | ||
{ | ||
return (T)value; | ||
} | ||
} | ||
else if (field.Name == enumText) | ||
{ | ||
var value = field.GetValue(null); | ||
if (value != null) | ||
{ | ||
return (T)value; | ||
} | ||
} | ||
} | ||
|
||
throw new JsonException($"Unable to convert \"{enumText}\" to Enum \"{typeToConvert}\"."); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) | ||
{ | ||
var field = value.GetType().GetField(value.ToString()); | ||
|
||
if (field != null) | ||
{ | ||
var attribute = Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)) as EnumMemberAttribute; | ||
|
||
if (attribute != null) | ||
{ | ||
writer.WriteStringValue(attribute.Value); | ||
} | ||
else | ||
{ | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} | ||
else | ||
{ | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
namespace AzureOpenAIProxy.ApiApp.Endpoints; | ||
|
||
/// <summary> | ||
/// This represents the collection of the admin endpoint URLs. | ||
/// </summary> | ||
public static class AdminEndpointUrls | ||
{ | ||
/// <summary> | ||
/// Declares the admin event details endpoint. | ||
/// </summary> | ||
/// <remarks> | ||
/// - GET method for an event details | ||
/// - PUT method for update an event details | ||
/// </remarks> | ||
public const string AdminEventDetails = "/admin/events/{eventId}"; | ||
|
||
/// <summary> | ||
/// Declares the admin event list endpoint. | ||
/// </summary> | ||
/// <remarks> | ||
/// - Get method for listing all events | ||
/// - Post method for new event creation | ||
/// - GET method for listing all events | ||
/// - POST method for new event creation | ||
/// </remarks> | ||
public const string AdminEvents = "/admin/events"; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/AzureOpenAIProxy.ApiApp/Endpoints/PlaygroundEndpointUrls.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,15 @@ | ||
namespace AzureOpenAIProxy.ApiApp.Endpoints; | ||
|
||
/// <summary> | ||
/// This represents the collection of the playground endpoint URLs. | ||
/// </summary> | ||
public static class PlaygroundEndpointUrls | ||
{ | ||
/// <summary> | ||
/// Declares the event endpoint. | ||
/// </summary> | ||
/// <remarks> | ||
/// - GET method for listing all events | ||
/// </remarks> | ||
public const string Events = "/events"; | ||
} |
10 changes: 3 additions & 7 deletions
10
...AIProxy.ApiApp/Endpoints/EventEndpoint.cs → ...y.ApiApp/Endpoints/PlaygroundEndpoints.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
Oops, something went wrong.