Skip to content

Commit

Permalink
feat: Updated OpenAPI spec
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 30, 2024
1 parent dec8bc1 commit 590c20f
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 169 deletions.
3 changes: 2 additions & 1 deletion src/libs/DeepInfra/Generated/DeepInfra.Models.ApiToken.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public sealed partial class ApiToken
/// creation unix timestamp
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("created_at")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.UnixTimestampJsonConverter))]
[global::System.Text.Json.Serialization.JsonRequired]
public required int CreatedAt { get; set; }
public required global::System.DateTimeOffset CreatedAt { get; set; }

/// <summary>
///
Expand Down
39 changes: 39 additions & 0 deletions src/libs/DeepInfra/Generated/JsonConverters.UnixTimestamp.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public class UnixTimestampJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::System.DateTimeOffset>
{
/// <inheritdoc />
public override global::System.DateTimeOffset Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
if (reader.TokenType == global::System.Text.Json.JsonTokenType.Number)
{
if (reader.TryGetInt64(out long unixTimestamp))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestamp);
}
if (reader.TryGetInt32(out int unixTimestampInt))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestampInt);
}
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::System.DateTimeOffset value,
global::System.Text.Json.JsonSerializerOptions options)
{
long unixTimestamp = value.ToUnixTimeSeconds();
writer.WriteNumberValue(unixTimestamp);
}
}
}
Loading

0 comments on commit 590c20f

Please sign in to comment.