-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix RangeAttribute behaviour #3449
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
- Use invariant culture when values are `double`. - Use `decimal.TryParse()` not `Convert.ToDecimal()` so that invalid values are just ignored like they were before. - Remove duplicate test case.
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 #3449 +/- ##
=======================================
Coverage 93.54% 93.55%
=======================================
Files 110 110
Lines 3829 3833 +4
Branches 713 715 +2
=======================================
+ Hits 3582 3586 +4
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
This PR refines RangeAttribute handling by switching to invariant culture for double limits, replacing Convert.ToDecimal with decimal.TryParse, and tidying up tests.
- Swap
Convert.ToDecimalfor culture-awaredecimal.TryParseon stringified limits - Add a unit test to verify invalid range values are ignored
- Remove a duplicated test case in
TheoryData
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/OpenApiSchemaExtensionsTests.cs | Drop duplicate entry; add Apply_Invalid_RangeAttribute_Values test |
| src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs | Update ApplyRangeAttribute to use decimal.TryParse and invariant culture |
double.decimal.TryParse()notConvert.ToDecimal()so that invalid values are just ignored like they were before.