Releases: micro-elements/MicroElements.Swashbuckle.FluentValidation
Releases · micro-elements/MicroElements.Swashbuckle.FluentValidation
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
v7.0.5
Changes in 7.0.5
- Added:
RemoveUnusedQuerySchemasoption (default:true) to control cleanup of container type schemas for[FromQuery]/[AsParameters]types (Issue #180)
User-facing API
services.AddFluentValidationRulesToSwagger(options =>
{
options.RemoveUnusedQuerySchemas = false; // preserve schemas for custom DocumentFilters
});Default is true (v7.0.4 behavior preserved). Set to false if you have custom IDocumentFilter implementations that depend on container type schemas being present in components/schemas.
7.1.0-beta.1
New package: MicroElements.AspNetCore.OpenApi.FluentValidation
First-class support for Microsoft.AspNetCore.OpenApi — generate OpenAPI schemas from FluentValidation rules without Swashbuckle.
Highlights
- New NuGet package
MicroElements.AspNetCore.OpenApi.FluentValidation - Implements
IOpenApiSchemaTransformerfor seamless integration withMicrosoft.AspNetCore.OpenApi - Targets .NET 9 and .NET 10
- Zero dependency on Swashbuckle
Supported validation rules
Required, NotNull, NotEmpty, Length, MinLength, MaxLength, Pattern, Email, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, InclusiveBetween, ExclusiveBetween
Usage
services.AddFluentValidationRulesToOpenApi();
services.AddOpenApi(options => options.AddFluentValidationRules());Migration from Swashbuckle
- MicroElements.Swashbuckle.FluentValidation
+ MicroElements.AspNetCore.OpenApi.FluentValidation
- services.AddFluentValidationRulesToSwagger();
+ services.AddFluentValidationRulesToOpenApi();
+ services.AddOpenApi(options => options.AddFluentValidationRules());What's included
- AllOf/OneOf/AnyOf sub-schema traversal for polymorphic/inheritance models
- .NET 10: full nested validator support via
GetOrCreateSchemaAsync - .NET 9: limited nested validator support (fallback to empty schema)
- Sample project
SampleAspNetCoreOpenApi - Architecture Decision Record (ADR-001)
Full changelog
See CHANGELOG.md
7.0.4
Changes in 7.0.4
- Fixed:
[AsParameters]types in minimal API and[FromQuery]container types create unused schemas incomponents/schemas(Issue #180) - Added: Support for keyed DI services (Issue #165)
- Validators registered via
AddKeyedScoped,AddKeyedTransient,AddKeyedSingletonare now discovered automatically
- Validators registered via
- Removed: Deprecated
FluentValidation.AspNetCorepackage reference (Issue #164)- Replaced with
FluentValidation.DependencyInjectionExtensions12.0.0
- Replaced with