Skip to content

7.2.0

Choose a tag to compare

@avgalex avgalex released this 12 Jul 20:42
· 8 commits to master since this release
b83b7cc

Added — the document-filter pipeline is now a supported opt-in (UseDocumentFilter)

services.AddFluentValidationRulesToSwagger(
    configureRegistration: options => options.UseDocumentFilter = true);

The document filter processes the whole OpenAPI document at once — component schemas, operation parameters and request bodies — and performs the unused-query-schema cleanup once at the end. Because there is no per-operation state, the shared-DTO bug class (#223, #226) cannot occur in this pipeline, on any target framework — including net8.0/net9.0, where the 7.1.11 fix could not fully apply (the ReplaceSchemaId healing API only exists in Swashbuckle 10.1.0+).

Full parity with the default pipeline

Previously the filter was experimental with significant gaps. Now it matches the default schema + operation filter pipeline:

  • Required-marking with the whole-dot-path check (#209)
  • Request bodies and encoding.contentType for [FromForm] uploads (#216)
  • Multiple validators per type, allOf/oneOf/anyOf traversal
  • $ref preservation for properties untouched by rules (#198, net10.0)
  • Every operation of a multi-verb path is processed (previously only the first)
  • On net10.0 the cleanup also clears Swashbuckle's internal reserved-ids for processed container types, so custom document filters running afterwards can regenerate them

The #209 and #216 logic is shared between both pipelines via internal components, so they cannot drift apart.

Robustness

A throwing validator no longer fails the whole document generation; the filter falls back to ServiceProviderValidatorRegistry like the sibling filters and honors an injected IFluentValidationRuleProvider (new optional constructor parameter, appended last — source-compatible). Behavior note: constructing the filter directly with neither validatorRegistry nor serviceProvider now throws ArgumentNullException instead of silently applying no rules; the DI path is unaffected.

Compatibility

  • The default pipeline is unchangedUseDocumentFilter defaults to false. A future major version may switch the default.
  • ExperimentalUseDocumentFilter still works as an [Obsolete] alias forwarding to UseDocumentFilter.
  • samples/MinimalApi now runs on the document-filter pipeline; the README documents the option and its caveats.

Full changelog: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/blob/master/CHANGELOG.md