Skip to content

Add configurable RemoveUnusedQuerySchemas option (Issue #180)#190

Closed
avgalex wants to merge 2 commits intomasterfrom
feature/configurable-schema-cleanup
Closed

Add configurable RemoveUnusedQuerySchemas option (Issue #180)#190
avgalex wants to merge 2 commits intomasterfrom
feature/configurable-schema-cleanup

Conversation

@avgalex
Copy link
Member

@avgalex avgalex commented Feb 26, 2026

Summary

  • Added RemoveUnusedQuerySchemas option (default: true) to SchemaGenerationOptions allowing users to opt out of the v7.0.4 schema cleanup
  • When set to false, container type schemas created for [FromQuery]/[AsParameters] types are preserved in components/schemas for use by custom DocumentFilters
  • Fixes regression reported by @thunderstatic in #180 (comment)
  • Version bumped to 7.0.5

User-facing API

services.AddFluentValidationRulesToSwagger(options =>
{
    options.RemoveUnusedQuerySchemas = false; // preserve schemas for custom DocumentFilters
});

Changes

File Change
ISchemaGenerationOptions.cs Added RemoveUnusedQuerySchemas to interface and class (default true)
SchemaGenerationOptionsExtensions.cs Copy new property in SetFrom()
FluentValidationOperationFilter.cs Conditional snapshot/cleanup based on flag
FluentValidationDocumentFilter.cs Conditional snapshot/cleanup based on flag
AsParametersTests.cs 4 new tests (default value, OperationFilter opt-out, DocumentFilter opt-out, DocumentFilter default)
CHANGELOG.md v7.0.5 entry
version.props Bumped to 7.0.5
ADR-002-configurable-schema-cleanup.md Architecture decision record

Test plan

  • All existing tests pass (default true preserves v7.0.4 behavior)
  • Default_RemoveUnusedQuerySchemas_Should_Be_True — verifies default
  • OperationFilter_Should_Preserve_Schemas_When_RemoveUnusedQuerySchemas_Is_False — opt-out works in OperationFilter
  • DocumentFilter_Should_Preserve_Schemas_When_RemoveUnusedQuerySchemas_Is_False — opt-out works in DocumentFilter
  • DocumentFilter_Should_Cleanup_ContainerType_Schemas_By_Default — default cleanup works in DocumentFilter
  • Builds and tests pass on net8.0, net9.0, net10.0

🤖 Generated with Claude Code

avgalex and others added 2 commits February 26, 2026 23:16
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>
Resolve conflicts: keep 7.0.5 version, preserve 7.1.0-beta.1 changelog entry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@avgalex
Copy link
Member Author

avgalex commented Feb 26, 2026

Replaced by release/v7.0.5 branch — hotfix off v7.0.4 without merging master (7.1.0-beta.1)

@avgalex avgalex closed this Feb 26, 2026
@avgalex avgalex deleted the feature/configurable-schema-cleanup branch February 26, 2026 20:43
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