Skip to content

Fix AspNetCore.OpenApi.FluentValidation for .NET 10 + merge v7.0.5/v7.0.6#192

Merged
avgalex merged 4 commits intomicro-elements:masterfrom
avgalex:fix/aspnetcore-openapi-net10
Mar 6, 2026
Merged

Fix AspNetCore.OpenApi.FluentValidation for .NET 10 + merge v7.0.5/v7.0.6#192
avgalex merged 4 commits intomicro-elements:masterfrom
avgalex:fix/aspnetcore-openapi-net10

Conversation

@avgalex
Copy link
Member

@avgalex avgalex commented Mar 6, 2026

Summary

  • Fix .NET 10 support for AspNetCore.OpenApi package (Issue Fluent validation rules in .NET 9 OpenApi #149)
    • Change ScopedTransient DI registration for FluentValidationSchemaTransformer and IValidatorRegistry — .NET 10 build-time document generation (OpenApiGenerateDocuments) runs without HTTP scope, causing scoped resolution to fail
    • Add debug-level logging when no validators found for a type
    • Use PropertiesCount() helper for consistency in ProcessAllSchemas
    • Document OpenApiSchemaReference null behavior in GetProperty()
  • Update sample app to multi-target net9.0;net10.0 with CustomerType enum
  • Add integration test project (MicroElements.AspNetCore.OpenApi.FluentValidation.Tests) with 4 WebApplicationFactory-based tests
  • Merge v7.0.5: configurable RemoveUnusedQuerySchemas option (Issue Validators for records used with [AsParameters] create unused component schemas #180)
  • Merge v7.0.6: [AsParameters] .NET 8 ContainerType null fix (Issue Validators for records used with [AsParameters] create unused component schemas #180)
  • Update ADR-001 with post-beta findings (Section 8)
  • Version: 7.1.0-beta.2

Test plan

  • dotnet build succeeds for all target frameworks
  • dotnet test --framework net9.0 — 66 tests pass (62 Swashbuckle + 4 AspNetCore)
  • dotnet test --framework net10.0 — 56 tests pass (52 Swashbuckle + 4 AspNetCore)
  • Sample app on .NET 10 → /openapi/v1.json contains validation constraints
  • Enum property (CustomerType) does not crash on .NET 10
  • FluentValidationSchemaTransformer resolves without scope (build-time compat)

🤖 Generated with Claude Code

avgalex and others added 4 commits February 26, 2026 23:24
…s#180)

Add RemoveUnusedQuerySchemas property (default: true) to SchemaGenerationOptions
to allow users to opt out of the v7.0.4 schema cleanup that removes side-effect
schemas from components/schemas when processing [FromQuery]/[AsParameters] types.
This fixes a regression where custom DocumentFilters that depend on these schemas
stopped working after v7.0.4.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…o-elements#180)

On .NET 8, ModelMetadata.ContainerType is null for [AsParameters]
decomposed parameters. Added AsParametersHelper fallback that resolves
the container type via [AsParameters] reflection on MethodInfo.
Applied in both FluentValidationOperationFilter and
FluentValidationDocumentFilter. Zero regression on .NET 9/10.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ents#149)

Change Scoped DI registrations to Transient for FluentValidationSchemaTransformer
and IValidatorRegistry to support .NET 10 build-time document generation which
runs without an HTTP scope. Add diagnostic logging, integration tests with
WebApplicationFactory, and update sample app to target net9.0;net10.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merges configurable RemoveUnusedQuerySchemas option (v7.0.5) and
[AsParameters] .NET 8 ContainerType null fix (v7.0.6) into the
AspNetCore.OpenApi .NET 10 fix branch. Version remains 7.1.0-beta.2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@avgalex avgalex merged commit 15353e5 into micro-elements:master Mar 6, 2026
2 checks passed
@avgalex avgalex mentioned this pull request Mar 9, 2026
3 tasks
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.

1 participant