7.1.10
Fixed — Issue #223: a [FromQuery] DTO shared by several endpoints lost its rules on every endpoint after the first
When the same [FromQuery]/[AsParameters] DTO was bound by more than one endpoint, only the first operation received FluentValidation constraints (minLength, pattern, maximum, ...) — every subsequent endpoint silently lost them. Reproduces with the default RemoveUnusedQuerySchemas = true.
app.MapGet("/hello1", ([FromQuery] HelloRequest request) => ...); // constraints emitted
app.MapGet("/hello2", ([FromQuery] HelloRequest request) => ...); // before: constraints lost — after: emitted- Root cause:
FluentValidationOperationFilterruns once per operation. The Issue #180 cleanup removes the temporary[FromQuery]container schema fromSchemaRepository.Schemas, but Swashbuckle also keeps the type in its internal reserved-ids map, which the cleanup cannot touch. For the 2nd+ endpointGenerateSchemathen returns a bare$refwith noProperties, so the "has properties" guard skipped all rules. - Fix:
SwashbuckleSchemaProvider.GetSchemaForTypedetects this reserved-but-removed state and recovers the concrete schema by generating it into a throwawaySchemaRepository. Fully isolated — the shared repository and its reserved-id state are never mutated — so the Issue #180 cleanup and all other operation-filter behavior (required marking #209, nested[FromQuery]#211/#213, request bodies andencoding.contentType#216) are preserved. - Follow-up hardening is tracked in #226: body-bound shared DTOs, and a
ReplaceSchemaId-based state-healing cleanup on the net10.0 target (needs Swashbuckle >= 10.1.0).
Thanks to @jgarciadelanoceda for the report and the ReplaceSchemaId discussion.
Full changelog: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/blob/master/CHANGELOG.md