7.1.11
Fixed — Issue #226: a DTO shared between [FromQuery] and a request body lost its rules, and the document could contain a dangling $ref (net10.0)
When the same DTO was bound as a flattened [FromQuery]/[AsParameters] container by one endpoint and as a request body ([FromBody]/[FromForm]) by another, the per-operation schema cleanup left the type "reserved-but-removed" inside Swashbuckle's SchemaRepository. The body operation then emitted a $ref to a component that no longer exists — an invalid document — and the FluentValidation constraints never reached it. Reproduces with the default RemoveUnusedQuerySchemas = true.
app.MapGet("/search", ([FromQuery] HelloRequest request) => ...); // processed first: cleanup runs
app.MapPost("/hello", ([FromBody] HelloRequest request) => ...); // before: $ref to a missing component, no rules
// after: component regenerated, rules applied- Root cause: the Issue #180 cleanup could remove the side-effect component schema, but Swashbuckle's internal reserved-ids map was unreachable via public API, so
GenerateSchemakept returning a bare$refwithout regenerating the component. The 7.1.10 fix (#223) recovered the schema for reading constraint values only; it could not restore the document's component. - Fix (net10.0 target, Swashbuckle 10.x): the cleanup now heals the repository state using
SchemaRepository.ReplaceSchemaId(public API since Swashbuckle 10.1.0) before removing a side-effect schema — the reservation is cleared together with the component, so the next operation binding the same type regenerates a full component and the rules reach the real document object. - net8.0/net9.0 pin Swashbuckle 8.1.1, where
ReplaceSchemaIddoes not exist — they keep the 7.1.10 throwaway-recovery behavior (parameters path). The recovery also remains as a safety net on all targets. - No public API changes.
Thanks to @jgarciadelanoceda for suggesting the ReplaceSchemaId approach (added in domaindrivendev/Swashbuckle.AspNetCore#3708).
Full changelog: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/blob/master/CHANGELOG.md