-
-
Notifications
You must be signed in to change notification settings - Fork 1
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:Add custom JSON converter for Unix timestamps and update TenantStats class #42
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/libs/LangSmith/Generated/JsonConverters.UnixTimestamp.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,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); | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Review of new property
DeploymentCount
inTenantStats
class.The addition of the
DeploymentCount
property is well-integrated with the existing structure of theTenantStats
class. The property is marked as required and uses the JSON property name "deployment_count", which is consistent with the naming conventions of other properties in the class.[JsonRequired]
ensures that the property must be present during deserialization, which is crucial for data integrity.DeploymentCount
represents for better code readability and maintenance.Overall, the property is correctly implemented, but enhancing the documentation would improve the code quality.
Consider adding a description to the summary documentation for the
DeploymentCount
property to enhance clarity and maintainability.Committable suggestion