Skip to content

Conversation

@martincostello
Copy link
Collaborator

  • Port tests for [RangeAttribute] from Support .NET 10 #3283.
  • Respect RangeAttribute.ParseLimitsInInvariantCulture.
  • Refactor to avoid redundant reassignment.
  • Avoid converting int values to a string and re-parsing.

- 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.
@martincostello martincostello added this to the v8.1.5 milestone Jun 6, 2025
@codecov
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.54%. Comparing base (61c0934) to head (71628a8).
Report is 1 commits behind head on master.

✅ 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           
Flag Coverage Δ
Linux 93.54% <100.00%> (+<0.01%) ⬆️
Windows 93.54% <100.00%> (+<0.01%) ⬆️
macOS 93.54% <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 changed the title Rangeattribute tests Add tests for RangeAttribute and respect ParseLimitsInInvariantCulture property Jun 6, 2025
@martincostello martincostello marked this pull request as ready for review June 6, 2025 12:11
Copilot AI review requested due to automatic review settings June 6, 2025 12:11
@martincostello martincostello merged commit cc663df into master Jun 6, 2025
11 checks passed
@martincostello martincostello deleted the rangeattribute-tests branch June 6, 2025 12:12
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

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 OpenApiSchemaExtensionsTests covering integer, floating, and decimal ranges under various cultures.
  • Refactors ApplyRangeAttribute to directly convert limits using the correct culture and eliminate extra ToString()/Parse calls.
  • Adds a CultureSwitcher helper to set and restore CurrentCulture.

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.

@martincostello martincostello modified the milestones: v8.1.5, v9.0.0 Jun 13, 2025
This was referenced Jul 28, 2025
This was referenced Nov 12, 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