Repository navigation
7.2.3
Fixed — identity ChildRules constraints were missing from OpenAPI
Constraints declared through an identity child rule now appear on the owning property or collection item:
RuleFor(x => x.Country)
.ChildRules(child => child.RuleFor(x => x).Matches("^[A-Z]{2}$"));Previously, the generated Country schema was missing the regex pattern: the child rule validates the value itself rather than a named member, so its constraints were not associated with the owning property.
The fix supports nested identity validators and shared child-validator instances, honors rule/component filters and conditional-rule settings, and prevents recursive identity traversal. An unresolvable runtime-dependent child validator does not discard the parent's constraints.
Applies to Swashbuckle, NSwag, and Microsoft.AspNetCore.OpenApi.
Nullability and constraint preservation
Child validators are skipped by FluentValidation when their parent value is null. Inner NotNull/NotEmpty rules therefore no longer make an optional parent property required or non-nullable in the generated schema.
- Non-empty string and array constraints are retained as
minLength/minItems. - Explicit
NotNull/NotEmptyrules on the parent continue to make it required. - NSwag preserves stronger parent minimum-length constraints regardless of rule order.
- Length constraints are emitted only for string/array schemas.
Compatibility and validation
Patch release — no public API changes. Runtime validation is unchanged. Schema generation does not execute Must predicates or infer constraints from DependentRules.
569 tests passed locally across the supported .NET 8/9/10 targets, including 55 new regression checks. Release solution build and four local 7.2.3 NuGet packages were verified. The PR CI passed on both Linux and Windows.
Thanks to @jgarciadelanoceda for the fix and for testing it in a real application.
PR: #235
Full changelog: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/blob/v7.2.3/CHANGELOG.md