- 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
- 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
- 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
- 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
- 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
- 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
- Added: Sample project
SampleAspNetCoreOpenApidemonstrating Microsoft.AspNetCore.OpenApi integration - Added: ADR-001 documenting the architectural decision for AspNetCore.OpenApi support
- 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,
- Added:
RemoveUnusedQuerySchemasoption (default:true) to control cleanup of container type schemas for[FromQuery]/[AsParameters]types (Issue #180)
- 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
- Fixed: NullReferenceException when models contain nested object properties (Issue #176 extended)
- Handle
OpenApiSchemaReferencefor nested class properties inOpenApiRuleContext - Add safe
TryGetValuecheck inNSwagRuleContext
- Handle
- Fixed: InvalidCastException when models contain enum properties (Issue #176)
- In Microsoft.OpenApi 2.x, enum properties are represented as
OpenApiSchemaReferenceinstead ofOpenApiSchema - Filter out schema references in
GetProperties()method to avoid cast exception
- In Microsoft.OpenApi 2.x, enum properties are represented as
- Fixed: FluentValidation rules not applied to
[FromForm]parameters (Issue #170)- Added
RequestBodyprocessing inFluentValidationOperationFilterformultipart/form-dataandapplication/x-www-form-urlencodedcontent types
- Added
- Added support for .NET 8 and .NET 9 to MicroElements.Swashbuckle.FluentValidation.AspNetCore
- Dropped support for .NET 6.0
- Updated NJsonSchema to version 10.6.10
- see changelog for betas
- Added:
IFluentValidationRuleProvidercan be replaced with DI - Added:
ISchemaGenerationOptions.ValidatorSearchIsOneValidatorForType: bool; Valuetrue: Gets only one validator (default),false: Gets all suitable validators (new)SearchBaseTypeValidators: allows to search base type validators
- Fixed: Stack Overflow Exception when using recursive validator type (PR#122 by @rachelpetitto)
- Deleted:
FluentValidationRulesRegistrator - Deleted:
SwaggerGenOptionsfrom filters - Many minor code cleanups
- Codebase unified with NSwag
- Added: MicroElements.NSwag.FluentValidation package. Early version
- Change:
INameResolverremoved from FluentValidationRules ctor. Set it fromSchemaGenerationOptions - Change:
ISchemaGenerationSettingsmerged toISchemaGenerationOptions - Change:
IValidatorRegistryand it's implementations moved to MicroElements.OpenApi.FluentValidation namespace and package - Change:
IValidatorRegistrycan return more than one validator with methodGetValidators - Added:
ValidatorSearchstrategy OneForType, ManyForType - Added:
ISchemaGenerationOptions.ValidatorFilter,ISchemaGenerationOptions.RuleFilter,ISchemaGenerationOptions.RuleComponentFilter- Default Rule and RuleComponent filters checks that rule or component has no conditions.
- Default ValidatorFilter checks that validator CanValidateInstancesOfType
- Change:
UseAllOfForMultipleRulestypo fix
- Abstracted common logic for NSwag
- Moved from
IValidationFactory(obsolete in FV 11.1.0) toIValidationRegistry - Supported FluentValidation 11
AddFluentValidationAutoValidation - Removed
HttpContextServiceProviderValidatorFactory - Experimental
DocumentFilter
- Change: ILengthValidator support for arrays. Sets MinItems, MaxItems (PR#108 by biggik)
- Supported FluentValidation 11
- Sets min compatibility to Swashbuckle.AspNetCore 6.3.0. (PR#102 by guimabdo)
- Adding additional fields (Enum, Description) for overridden schema in FluentValidationOperationFilter. (PR#95 by kritsda-jiwatrakan)
- Fixed Issue #94: Rule with overridden property name unexpectedly applied to property
- Fixed case with many rules for one property. Issue #92
- Change: NotEmpty rule sets minItems for arrays instead minLength.
- Use new registration method AddFluentValidationRulesToSwagger instead of AddFluentValidationRules to allow all feature set
- AddFluentValidationRules become obsolete
- Added ability to set ServiceLifetime in AddFluentValidationRulesToSwagger, default value: Scoped. Fixes #83
- Turned off test rule BeforeAll. Fixes #87
- More detailed warnings in FluentValidationRulesScopeAdapter
- Added detailed error on getting absent property by name
- FluentValidation updated to 10.0.0
- Swashbuckle.AspNetCore updated to 6.0.0
- RuleContext: Obsolete SchemaFilterContext replaced with ReflectionContext (removed dependency on Swashbuckle)
- Dependency Swashbuckle.AspNetCore changed to Swashbuckle.AspNetCore.SwaggerGen which is UI independent (PR#82 by buvinghausen)
- Added INameResolver to resolve names. Issue #80
- Added AddFluentValidationRulesToSwagger extensions to simplify registration
- FluentValidationSwaggerGenOptions renamed to SchemaGenerationOptions, IsAllOffSupported renamed to UseAllOffForMultipleRules
- Fixed #79: Adding a simple Length validation to a string field should not make the field non-nullable
- Fixed #76: SetValidator is applying FluentValidation rules to parent object property with same name
- Swashbuckle.AspNetCore version supports up to 7 (PR#75 by fabich)
- RuleForEach supported. Issue #66
- SetValidator supported. Issue #68
- Multiple match rules supported with allOf. Issue #69
- Fixed #67: Absence of MinimumLength should not override nullable. (PR#67 by bcronje)
- Fixed #70: Nullability for numerics if MinLength is greater then zero
- Nullable annotations added
- FluentValidation updated to [9.0.0]
- Swashbuckle.AspNetCore updated to [5.5.1]
- Changed getting included validator (FluentValidation internal API changed)
- New EmailValidator rule compatible with FluentValidation AspNetCoreCompatibleEmailValidator
- FluentValidation fix version to [8.3.0, 9)
- Swashbuckle.AspNetCore fix version to [5.2.0, 6)
- Base type for numeric switched to decimal to match type change in OpenApi. Fixes floating numbers with nines after period.
- More smart MinLength, MaxLength, Minimum, Maximum that allows to combine rules without override values.
- More strict limits will be used for min and max values that was set more then once in other rules
- Mark required properties as not nullable (PR#58 by @manne) Fixes: #55, #57
- Swashbuckle.AspNetCore updated to version >= 5.2.0
- Fixed: #53 (Missing method exception when using Swashbuckle > 5.0.0)
-
Supports Swashbuckle 5, net core 3 and brand new System.Text.Json
-
Swashbuckle.AspNetCore updated to version >= 5.0.0 (new Microsoft.OpenApi)
-
FluentValidation updated to version >= 8.3
-
FluentValidation property rules of type CollectionValidationRules (RuleForEach()) are no longer exposed #49.
-
New IgnoreAllStringComparer was invented to solve problem with different property name formatting: camelCase, PascalCase, snake_case, kebab-case
-
Added NewtonsoftJsonNamingPolicy example to override property name formatting in new System.Text.Json according Newtonsoft.Json.Serialization.NamingStrategy (see: SampleWebApi)
-
Fixed invalid documentation on validation rules containing a condition #38
-
Fixed: #37 (FluentValidationOperationFilter now uses swachbuckle interface to determine json settings)
- Swashbuckle.AspNetCore updated to version >= 5.0.0
- FluentValidation property rules of type CollectionValidationRules (RuleForEach()) are no longer exposed #49.
- Swashbuckle.AspNetCore updated to version >= 5.0.0-rc4 (breaking changes: IApiModelResolver was removed from API)
- New IgnoreAllStringComparer was invented to solve problem with different property name formatting: camelCase, PascalCase, snake_case, kebab-case
- Added NewtonsoftJsonNamingPolicy example to override property name formatting in new System.Text.Json according Newtonsoft.Json.Serialization.NamingStrategy (see: SampleWebApi)
- Updated FluentValidation to version >= 8.3
- Fixed invalid documentation on validation rules containing a condition #38
- Swashbuckle.AspNetCore updated to version >= 5.0.0-rc4
- Fixed: #37 (FluentValidationOperationFilter now uses swachbuckle interface to determine json settings)
- Swashbuckle.AspNetCore updated to version >= 5.0.0-rc3 (PR#35 by @vova-lantsov-dev)
- Reintegrated features from 2.2.0
- Swashbuckle.AspNetCore updated to version >= 5.0.0-rc2 (many breaking changes)
- Swashbuckle.AspNetCore updated to version >= 5.0.0-beta
- Added HttpContextServiceProviderValidatorFactory to resolve scoped Dependency Injection (PR#34) by @WarpSpideR
- Fixed MinLength rewrite by MaxLength validator #32
- Changes: Allow to use SwaggerGenOptions.CustomSchemaIds (PR#31) by @mkjeff
- Fixed: #24: NullReferenceException on apply rule for operations.
- Changes: Added more debug logging.
- Swashbuckle.AspNetCore updated and restricted to version [4.0.0, 5.0.0)
- Breaking Changes: FluentValidation updated to 8.1.3 to support when/unless (PR#27) by @emilssonn
- Changes: Running through included validators recursively to add the entire tree (PR#29) by @runebaekkelund
- Changes: Numeric types includes decimal
- Changes: Schema Minimum and Maximum now supports doubles (was only int)
- WARNING: ScopedSwaggerMiddleware doesn't work as expected because Swashbuckle.AspNetCore changed a lot. Looking for workaround.
- Added: Numeric types includes decimal
- Swashbuckle.AspNetCore version locked to versions [1.1.0-3.0.0] because version 4.0.0 has breaking changes. Next version will be 2.0.0 according semver.
- Added ScopedSwaggerMiddleware to resolve error "Cannot resolve 'MyValidator' from root provider because it requires scoped service 'TDependency'"
- Added support for Include
- Bugfixes
- Updated samples and documentation
- Build scripts migrated to MicroElements.Devops
- Build: added SourceLink
- Fixed: #13: Fixed warning with null schema.Properties
- Fixed: #12: Fixed NullReferenceException, if schema.Properties is null
- New feature: FluentValidation rules for get operation parameters binded from models with validators. Adds swagger validation for parameters: Required, MinLength, MaxLength, Minimum, Maximum, Pattern (DataAnnotation works only with [Required]).
- Fixed: #10: Now member search is IgnoreCase
- Fixed: Possible double Required
- Improved stability and diagnostics
- Added GetValidator error handling, ApplyRule error handling
- Added ability to work without provided FluentValidation (does not break anything)
- Added ability to use Microsoft.Extensions.Logging.Abstractions (no additional dependencies)
- Added logging in error points (logs as warnings)
- Fixed: #6: Removed empty required array from swagger schema
- Supported float and double values for IComparisonValidator and IBetweenValidator
- Refactored to easy add new rules
- Added ability to add rules through DI Supported validators:
- INotNullValidator (NotNull)
- INotEmptyValidator (NotEmpty)
- ILengthValidator (Length, MinimumLength, MaximumLength, ExactLength)
- IRegularExpressionValidator (Email, Matches)
- IComparisonValidator (GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual)
- IBetweenValidator (InclusiveBetween, ExclusiveBetween)
- FluentValidationRulesRegistrator moved to main swagger namespace
- Added FluentValidationRulesRegistrator
- Added FluentValidationRules.
Full release notes can be found at https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/blob/master/CHANGELOG.md