Releases: micro-elements/MicroElements.Swashbuckle.FluentValidation
Releases · micro-elements/MicroElements.Swashbuckle.FluentValidation
7.1.5-beta.2
Pre-release for the upcoming 7.1.5.
Changes since 7.1.5-beta
- Fixed: Multiple
.Matches()rules on one property displayed incorrectly — only the first pattern shown, property duplicated (#204, #205).- Multiple patterns were placed into separate
allOfsubschemas, which Swagger UI/Redoc/Scalar collapse, keeping only the firstpattern. - Now multiple
.Matches()rules are combined into a singlepatternvia lookahead assertions, preserving.Matches()semantics and rendering correctly. - Applied to all providers: Swashbuckle,
MicroElements.AspNetCore.OpenApi.FluentValidation, and NSwag. - Behavior change:
SchemaGenerationOptions.UseAllOfForMultipleRulesdefaulttrue→false; set it totrueto keep the legacyallOfrepresentation.
- Multiple patterns were placed into separate
Already in 7.1.5-beta
- Added:
ConditionalRulesModeoption to control how.When()/.Unless()conditional rules are handled during schema generation (#203).
See CHANGELOG.md for full details.
v7.1.5-beta
What's New
ConditionalRulesMode option (Issue #203)
Controls how conditional validation rules (.When(), .Unless()) are handled during OpenAPI schema generation.
Modes:
Exclude(default) — conditional rules are excluded from schema (backward-compatible)Include— conditional rules are included in schemaIncludeWithWarning— same as Include, but logs a warning for each conditional rule
Usage:
services.AddFluentValidationRulesToSwagger(options =>
{
options.ConditionalRules = ConditionalRulesMode.Include;
});Why: When users write .When(x => x.Prop is not null) as a null-guard, validation constraints (minLength, maxLength, etc.) were silently dropped from the schema. This option lets users opt-in to including those constraints.
v7.1.4
Changes in 7.1.4
- Added:
FluentValidationOperationTransformer(IOpenApiOperationTransformer) forMicroElements.AspNetCore.OpenApi.FluentValidation(Issue #200)- Query parameters with
[AsParameters]now receive validation constraints (min/max, required, pattern, etc.) - Supports container type resolution with fallback via reflection for
[AsParameters] - Copies validation constraints from schema properties to parameter schemas
- Registered automatically via
AddFluentValidationRules()
- Query parameters with
- Fixed: Nested DTOs in request body not receiving validation constraints (Issue #200)
FluentValidationSchemaTransformerskipped all property-level schemas, but for nested object types this was the only transformer call- Now processes property-level schemas for complex types using the property type's validator
v7.1.4-beta
Changes in 7.1.4-beta
- Added:
FluentValidationOperationTransformer(IOpenApiOperationTransformer) forMicroElements.AspNetCore.OpenApi.FluentValidation(Issue #200)- Query parameters with
[AsParameters]now receive validation constraints (min/max, required, pattern, etc.) - Supports container type resolution with fallback via reflection for
[AsParameters] - Copies validation constraints from schema properties to parameter schemas
- Registered automatically via
AddFluentValidationRules()
- Query parameters with
- Fixed: Nested DTOs in request body not receiving validation constraints (Issue #200)
FluentValidationSchemaTransformerskipped all property-level schemas, but for nested object types this was the only transformer call- Now processes property-level schemas for complex types using the property type's validator
Full Changelog: v7.1.3...v7.1.4-beta
v7.1.3
Changes in 7.1.3
- Fixed:
$refreplaced with inline schema copy when usingSetValidatorwith nested object types (Issue #198)ResolveRefProperty(introduced in 7.1.2 for BigInteger isolation) replaced all$refproperties with copies, destroying reference structure in the OpenAPI document- Fix: snapshot
$refproperties before rule application, restore them afterwards if no validation constraints were added by rules - BigInteger per-model constraints (Issue #146) continue to work correctly
Full Changelog: v7.1.2...v7.1.3
v7.1.2
Changes in 7.1.2
- Added:
BigIntegersupport for min/max validation constraints in OpenAPI schema generation (Issue #146)IsNumeric()andNumericToDecimal()now handleBigIntegervaluesBigIntegerproperties with GreaterThan, LessThan, InclusiveBetween, ExclusiveBetween rules produce correctminimum/maximumin Swagger- NSwag provider updated with the same
BigIntegersupport - Out-of-range
BigIntegervalues (exceedingdecimalrange) are handled gracefully via existing try/catch
- Fixed: Shared schema mutation when multiple models reference the same
BigIntegertype with different constraints (net10.0)ResolveRefPropertycreates an isolated shallow copy before applying rule mutations- Prevents
$ref-based schema corruption across models inSchemaRepository
- Fixed: Replaced deprecated
PackageLicenseUrlwithPackageLicenseExpression(Issue #144) - Fixed: Replaced deprecated
PackageIconUrlwith embeddedPackageIcon
v7.1.1
Changes in 7.1.1
- Fixed: Nested object validation not applied for
[FromQuery]parameters (Issue #162)- When Swashbuckle decomposes
[FromQuery]models with nested objects into flat parameters (e.g.,operation.op), the full dot-path name was used for schema property matching instead of the leaf name (op) EqualsIgnoreAll("operation.op", "op")compared"OPERATIONOP"vs"OP"and failed to match- Strip dot-path prefix using
LastIndexOf('.')in bothFluentValidationOperationFilterandFluentValidationDocumentFilter - Supports arbitrarily deep nesting (e.g.,
a.b.c→c)
- When Swashbuckle decomposes
- Added:
SetNotNullableIfMinimumGreaterThenZerooption to separately control nullable behavior for numeric Minimum constraints (Issue #154, ported from vchirikov fork PR #2)- Distinct from existing
SetNotNullableIfMinLengthGreaterThenZero(for string MinLength) - Default:
false(backward compatible)
- Distinct from existing
- Fixed:
SetNotNullableIfMinLengthGreaterThenZerooption now works in NSwag provider (Issue #154)NSwagFluentValidationRuleProvidernow acceptsIOptions<SchemaGenerationOptions>- Rules NotEmpty, Length, Comparison, Between respect both nullable options
- Feature parity across Swashbuckle, AspNetCore.OpenApi, and NSwag providers
- Improved: Comparison/Between rules now use
SetNotNullableIfMinimumGreaterThenZero()which checks actual Minimum value instead of unconditionally setting not-nullable
v7.1.0
Changes in 7.1.0
- Added: New package
MicroElements.AspNetCore.OpenApi.FluentValidationfor Microsoft.AspNetCore.OpenApi support (Issue #149)- Implements
IOpenApiSchemaTransformerfor .NET 9 and .NET 10 - Supports all FluentValidation rules: Required, NotEmpty, Length, Pattern, Email, Comparison, Between
- Handles AllOf/OneOf/AnyOf sub-schemas for polymorphic models
- No dependency on Swashbuckle
- User-facing API:
services.AddFluentValidationRulesToOpenApi()+options.AddFluentValidationRules() - .NET 10: full nested validator support via
GetOrCreateSchemaAsync - .NET 9: limited nested validator support (fallback to empty schema)
- Implements
- Fixed: AspNetCore.OpenApi.FluentValidation support for .NET 10 (Issue #149, PR #192)
- Added: Sample project
SampleAspNetCoreOpenApidemonstrating Microsoft.AspNetCore.OpenApi integration - Added: ADR-001 documenting the architectural decision for AspNetCore.OpenApi support
v7.1.0-beta.2
Changes in 7.1.0-beta.2
AspNetCore.OpenApi.FluentValidation — .NET 10 fix (Issue #149)
- Fix: Scoped → Transient DI registration for
FluentValidationSchemaTransformerandIValidatorRegistry— .NET 10 build-time document generation (OpenApiGenerateDocuments) runs without HTTP scope - Add: Debug-level logging when no validators found for a type
- Add: Integration tests with
WebApplicationFactory(net9.0 + net10.0) - Update: Sample app multi-targets
net9.0;net10.0with enum property test - Update: ADR-001 with post-beta findings
Swashbuckle — merged from v7.0.5 / v7.0.6
- Add:
RemoveUnusedQuerySchemasoption to control schema cleanup (Issue #180) - Fix:
[AsParameters]validation rules not applied on .NET 8 —ContainerTypenull fallback (Issue #180)
Install
dotnet add package MicroElements.AspNetCore.OpenApi.FluentValidation --version 7.1.0-beta.2
dotnet add package MicroElements.Swashbuckle.FluentValidation --version 7.1.0-beta.2
v7.0.6
Changes in 7.0.6
- Fixed:
[AsParameters]validation rules not applied on .NET 8 Minimal APIs (Issue #180)- On .NET 8,
ModelMetadata.ContainerTypeis null for[AsParameters]decomposed parameters - Added
AsParametersHelperfallback that resolves the container type via[AsParameters]reflection onMethodInfo - Applied fallback in both
FluentValidationOperationFilterandFluentValidationDocumentFilter - Zero regression on .NET 9/10 where
ContainerTypeis already populated
- On .NET 8,
Full Changelog: v7.0.5...v7.0.6