-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add tests for RangeAttribute and respect ParseLimitsInInvariantCulture property #3448
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
Conversation
- Port tests for `[RangeAttribute]` from #3283. - Respect `RangeAttribute.ParseLimitsInInvariantCulture`. - Refactor to avoid redundant reassignment.
- Avoid converting `int` values to a string and re-parsing. - Add test case for decimal values.
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3448 +/- ##
=======================================
Coverage 93.54% 93.54%
=======================================
Files 110 110
Lines 3827 3829 +2
Branches 713 713
=======================================
+ Hits 3580 3582 +2
Misses 247 247
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
Adds comprehensive tests for RangeAttribute parsing across different cultures and updates the schema extension to honor the ParseLimitsInInvariantCulture flag while removing redundant parsing logic.
- Introduces
OpenApiSchemaExtensionsTestscovering integer, floating, and decimal ranges under various cultures. - Refactors
ApplyRangeAttributeto directly convert limits using the correct culture and eliminate extraToString()/Parsecalls. - Adds a
CultureSwitcherhelper to set and restoreCurrentCulture.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/OpenApiSchemaExtensionsTests.cs | New tests for RangeAttribute including culture-specific parsing and an empty‐string culture helper. |
| src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs | Updated ApplyRangeAttribute to use Convert.ToDecimal with culture and removed redundant parsing. |
[RangeAttribute]from Support .NET 10 #3283.RangeAttribute.ParseLimitsInInvariantCulture.intvalues to a string and re-parsing.