Skip to content
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

Extend built-in supported types #2804

Merged

Conversation

martincostello
Copy link
Collaborator

@martincostello martincostello commented Apr 16, 2024

  • Ensure DateOnly and TimeOnly with for Newtonsoft.Json.
  • Add System.Text.Json support for TimeSpan and Version.
  • Add Int128 and UInt128 support.
  • Handle AnnotationsDataType.Upload.
  • Create AnnotationsDataType mapping dictionary only once.

Resolves #2611
Relates to #2500

@codecov-commenter
Copy link

codecov-commenter commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.14%. Comparing base (c936acb) to head (8fab64d).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2804      +/-   ##
==========================================
+ Coverage   92.10%   92.14%   +0.04%     
==========================================
  Files          91       91              
  Lines        3064     3080      +16     
  Branches      525      526       +1     
==========================================
+ Hits         2822     2838      +16     
  Misses        242      242              
Flag Coverage Δ
Linux 92.14% <100.00%> (+0.04%) ⬆️
Windows 92.14% <100.00%> (+0.04%) ⬆️
macOS 92.14% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Ensure `DateOnly` and `TimeOnly` with for Newtonsoft.Json.
- Add System.Text.Json support for `TimeSpan` and `Version`.
- Add Int128 and UInt128 support.
- Handle `AnnotationsDataType.Upload`.
- Create `AnnotationsDataType` mapping dictionary only once.
Resolves domaindrivendev#2611.
- Use `TryGetValue()` instead of `ContainsKey()` and indexer.
- Apply some IDE refactoring suggestions.
@@ -186,7 +197,7 @@ private IEnumerable<DataProperty> GetDataPropertiesFor(JsonObjectContract jsonOb
return dataProperties;
}

private static readonly Dictionary<Type, Tuple<DataType, string>> PrimitiveTypesAndFormats = new Dictionary<Type, Tuple<DataType, string>>
private static readonly Dictionary<Type, Tuple<DataType, string>> PrimitiveTypesAndFormats = new()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static readonly Dictionary<Type, Tuple<DataType, string>> PrimitiveTypesAndFormats = new()
private static readonly Dictionary<Type, Tuple<DataType, string>> PrimitiveTypesAndFormats = new

@martincostello martincostello merged commit 4d5625f into domaindrivendev:master May 6, 2024
9 checks passed
@martincostello martincostello deleted the extend-type-support branch May 6, 2024 21:45
martincostello referenced this pull request in martincostello/Swashbuckle.AspNetCore May 8, 2024
Add test for domaindrivendev#2771 for `DateOnly` values.
Copy link

@vierlijner vierlijner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a #if NET6_0_OR_GREATER ... #endif (snippet) around the test inline data for dateonly and timeonly in the testfiles, like the example below. I can't suggest this change anymore.
#if NET6_0_OR_GREATER [InlineData(typeof(DateOnly), "string", "date")] [InlineData(typeof(TimeOnly), "string", "time")] #endif

@martincostello
Copy link
Collaborator Author

martincostello commented May 10, 2024

There was no need to do that in the Swashbuckle.AspNetCore.Newtonsoft.Test project because it already targets a minimum of .NET 6 so the condition would always have evaluated to true. The preprocessor condition was added where it was needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Int128 and UInt128 in schema generation
5 participants