Skip to content

fix: enforce strict JSON numbers - #7

Merged
PANiXiDA merged 1 commit into
mainfrom
feature/strict-json-numbers
Aug 2, 2026
Merged

fix: enforce strict JSON numbers#7
PANiXiDA merged 1 commit into
mainfrom
feature/strict-json-numbers

Conversation

@PANiXiDA

@PANiXiDA PANiXiDA commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Configured AddHttp to use JsonNumberHandling.Strict for HTTP JSON serialization.
  • Added regression coverage for strict numeric deserialization, string enum compatibility, and numeric OpenAPI schemas.
  • Documented the JSON contract in the README.

Why

ASP.NET Core web defaults allow numbers to be read from JSON strings. In .NET 10, OpenAPI 3.1 reflects that setting as integer | string and number | string, which prevents clients such as Kiota from generating scalar numeric properties.

How to verify

dotnet restore
dotnet format
dotnet build --configuration Release
dotnet test --configuration Release

All 75 package tests pass. The equivalent setting was also applied temporarily to the Tactical Heroes API host and all 487 solution tests passed.

Compatibility

  • Breaking behavior: quoted numbers in JSON request bodies are rejected; callers must send JSON numeric tokens.
  • OpenAPI numeric schemas change from unions to integer or number.
  • String properties and enums configured for string serialization are unchanged.
  • No migrations or configuration changes are required.

@PANiXiDA
PANiXiDA marked this pull request as ready for review August 2, 2026 16:33
@PANiXiDA
PANiXiDA merged commit c7315bd into main Aug 2, 2026
6 checks passed
@PANiXiDA
PANiXiDA deleted the feature/strict-json-numbers branch August 2, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants