Skip to content

Conversation

@martincostello
Copy link
Collaborator

  • 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.

- 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.
@martincostello martincostello added this to the v8.1.5 milestone Jun 6, 2025
Copilot AI review requested due to automatic review settings June 6, 2025 13:36
@codecov
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.55%. Comparing base (cc663df) to head (689fc2d).
Report is 1 commits behind head on master.

✅ 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           
Flag Coverage Δ
Linux 93.55% <100.00%> (+<0.01%) ⬆️
Windows 93.55% <100.00%> (+<0.01%) ⬆️
macOS 93.55% <100.00%> (+<0.01%) ⬆️

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.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello merged commit b0381a5 into master Jun 6, 2025
11 checks passed
@martincostello martincostello deleted the fix-range-handling branch June 6, 2025 13:41
Copy link

Copilot AI left a 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.ToDecimal for culture-aware decimal.TryParse on 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

@martincostello martincostello modified the milestones: v8.1.5, v9.0.0 Jun 13, 2025
This was referenced Jul 28, 2025
This was referenced Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants