-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[release/9.0] [OpenAPI] Use invariant culture for TextWriter #62239
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
base: release/9.0
Are you sure you want to change the base?
Conversation
Ensure OpenAPI documents are written to a culture-invariant `TextWriter` implementation. Resolves dotnet#60628.
@martincostello I updated the issue with the servicing template in case you'd like to review it and mark the PR as ready for review. |
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 addresses a culture-invariant formatting issue in OpenAPI document generation. When hosting applications under non-English cultures (like fr-FR), the OpenAPI serialization was producing incorrect JSON with locale-specific number formatting (e.g., using commas instead of dots for decimals).
- Introduces a new constructor for
Utf8BufferTextWriter
that accepts anIFormatProvider
- Updates the OpenAPI endpoint handler to use
CultureInfo.InvariantCulture
for serialization - Refactors test approach from direct document serialization to HTTP endpoint testing
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
Utf8BufferTextWriter.cs | Adds constructor overload accepting IFormatProvider for culture-invariant formatting |
OpenApiEndpointRouteBuilderExtensions.cs | Updates OpenAPI serialization to use invariant culture and creates new writer instance instead of pooled one |
OpenApiDocumentIntegrationTests.cs | Simplifies tests to use HTTP client instead of direct document service |
Program.cs | Adds middleware to set French culture for testing culture-invariant behavior |
TestController.cs | Adds test endpoint with float property to verify decimal formatting |
Multiple snapshot files | Updates test snapshots with new server URL and endpoint entries |
@captainsafia Thanks, done. I wanted to make sure you were happy with the changes/approach first before trying to guide it through shiproom. |
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.
LGTM!
servers
change to snapshots is expected since we move from resolving the document via the service to via the endpoint.
New test scenario matches what we have in main.
Hi @@martincostello. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed. |
@captainsafia tactics approved but asked the usual question about whether we scanned for variants (other instances)? |
Holding this for October at this point |
Use culture-invariant TextWriter implementation for OpenAPI.
Port of #62193 for .NET 9.
Description
To avoid any accidental changes to SignalR's use of
Utf8BufferTextWriter
I've removed the use of the writer pooling for OpenAPI and instead a new instance is created every time.Fixes #60628
Customer Impact
Developers run into this issue when hosting under non-en cultures, but no workarounds are available.
Regression?
Risk
Change is isolated to the OpenAPI serialization path and uses an existing overload; no impact on runtime behavior or other subsystems.
Verification
Packaging changes reviewed?