MicroElements.OpenApi.FluentValidation
7.1.8-beta.1
Prefix Reserved
See the version list below for details.
dotnet add package MicroElements.OpenApi.FluentValidation --version 7.1.8-beta.1
NuGet\Install-Package MicroElements.OpenApi.FluentValidation -Version 7.1.8-beta.1
<PackageReference Include="MicroElements.OpenApi.FluentValidation" Version="7.1.8-beta.1" />
<PackageVersion Include="MicroElements.OpenApi.FluentValidation" Version="7.1.8-beta.1" />
<PackageReference Include="MicroElements.OpenApi.FluentValidation" />
paket add MicroElements.OpenApi.FluentValidation --version 7.1.8-beta.1
#r "nuget: MicroElements.OpenApi.FluentValidation, 7.1.8-beta.1"
#:package MicroElements.OpenApi.FluentValidation@7.1.8-beta.1
#addin nuget:?package=MicroElements.OpenApi.FluentValidation&version=7.1.8-beta.1&prerelease
#tool nuget:?package=MicroElements.OpenApi.FluentValidation&version=7.1.8-beta.1&prerelease
Package Description
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FluentValidation (>= 12.0.0)
-
net8.0
- FluentValidation (>= 12.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Options (>= 9.0.5)
-
net9.0
- FluentValidation (>= 12.0.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on MicroElements.OpenApi.FluentValidation:
| Package | Downloads |
|---|---|
|
MicroElements.Swashbuckle.FluentValidation
Swagger ISchemaFilter that uses FluentValidation validators instead System.ComponentModel based attributes. |
|
|
MicroElements.NSwag.FluentValidation
Adds FluentValidation rules to swagger schema. |
|
|
MicroElements.AspNetCore.OpenApi.FluentValidation
Applies FluentValidation rules to OpenAPI schemas generated by Microsoft.AspNetCore.OpenApi (IOpenApiSchemaTransformer). |
|
|
X2031.MicroElements.NSwag.FluentValidation
Adds FluentValidation rules to swagger schema. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.1.8-beta.2 | 65 | 6/21/2026 |
| 7.1.8-beta.1 | 65 | 6/20/2026 |
| 7.1.7 | 3,332 | 6/20/2026 |
| 7.1.7-beta.3 | 143 | 6/17/2026 |
| 7.1.7-beta.2 | 77 | 6/17/2026 |
| 7.1.7-beta.1 | 70 | 6/15/2026 |
| 7.1.6 | 31,227 | 6/2/2026 |
| 7.1.6-beta.1 | 64 | 6/2/2026 |
| 7.1.5-beta.2 | 387 | 5/16/2026 |
| 7.1.5-beta | 535 | 4/1/2026 |
| 7.1.4 | 245,007 | 3/29/2026 |
| 7.1.4-beta | 1,505 | 3/24/2026 |
| 7.1.3 | 11,018 | 3/24/2026 |
| 7.1.2 | 66,833 | 3/9/2026 |
| 7.1.1 | 706 | 3/9/2026 |
| 7.1.0 | 699 | 3/9/2026 |
| 7.1.0-beta.2 | 431 | 3/6/2026 |
| 7.1.0-beta.1 | 1,852 | 2/23/2026 |
| 7.0.6 | 21,547 | 3/3/2026 |
| 7.0.5 | 10,986 | 2/26/2026 |
$# Changes in 7.1.8-beta.1
- Added: media type (content type) and file size validation for `IFormFile` uploads (Issue #216)
- New File-level FluentValidation rules in `MicroElements.OpenApi.FluentValidation` (namespace `MicroElements.OpenApi.FluentValidation.FileUpload`): `.FileContentType(params string[])`, `.MaxFileSize(long)`, `.MinFileSize(long)`, `.FileSizeBetween(long, long)` on `IRuleBuilder<T, IFormFile>`. They both enforce validation at runtime and surface metadata for OpenAPI generation
- Root cause: rules on nested `IFormFile` members (`RuleFor(x => x.File.Length)` / `RuleFor(x => x.File.ContentType)`) are named `File.Length` / `File.ContentType` and never match the flat schema property `File`, so they were silently dropped; and `Must(...)` is opaque so allowed content types could not be reflected. Use the new File-level rules instead
- **Swashbuckle**: emits `requestBody.content["multipart/form-data"].encoding.<part>.contentType` (comma-joined allowed types) and appends the allowed types and size limits to the file property `description`. File size is never emitted as `maxLength` (which counts characters, not bytes). Works on net8.0/net9.0 (Microsoft.OpenApi v1, OpenAPI 3.0) and net10.0 (Microsoft.OpenApi v2, OpenAPI 3.1)
- **NSwag**: a new `FluentValidationOperationProcessor` (`IOperationProcessor`) emits multipart encoding for file parts; the allowed types and size limits are also appended to the file part `description`. Register it alongside the schema processor: `settings.OperationProcessors.Add(serviceProvider.GetService<FluentValidationOperationProcessor>())`. Known NSwag limitation: `OpenApiEncoding.EncodingType` serializes as `encodingType` rather than the OpenAPI-spec `contentType` (through at least NSwag 14.7.x), so the `description` is the guaranteed-visible carrier
- **Microsoft.AspNetCore.OpenApi**: the allowed types and size limits are appended to the file property `description`. `encoding.contentType` is out of scope for this backend (its operation transformer has no mutable multipart request-body path)
- Purely additive / opt-in: behavior only changes when the new rules are used; no existing document output changes
- File size has no standard OpenAPI/JSON-Schema byte keyword, so it is documented in the `description` (annotation only; enforcement stays server-side via FluentValidation)
# Changes in 7.1.7
- Fixed: The nested `[FromQuery]` fixes (#209 + #211) now also apply to the native `Microsoft.AspNetCore.OpenApi` transformer and the experimental Swashbuckle DocumentFilter (Issue #213)
- `FluentValidationOperationTransformer` (package `MicroElements.AspNetCore.OpenApi.FluentValidation`) previously set a nested parameter `required` from the leaf validator alone — ignoring both whether the `SetValidator`/`ChildRules` chain reaches the leaf (#211) and whether every ancestor of the dot-path is required (#209). It now follows the same reachability + ancestor-required rules as the Swashbuckle `OperationFilter`
- The experimental `FluentValidationDocumentFilter` no longer copies value constraints onto a flattened nested parameter whose nested validation is not wired from the root validator (#211)
- `GetMethodInfo` now resolves the action method from `ControllerActionDescriptor` (MVC controllers), not only minimal-API endpoint metadata, so the dot-path root type can be resolved for controller actions
- NSwag is unaffected (it has no `[FromQuery]` parameter flattening)
- Fixed: A validator for a nested type bound via `[FromQuery]` was reflected in the OpenAPI document even when it was **not** wired into the root validator via `SetValidator`/`ChildRules` (Issue #211)
- `FluentValidationOperationFilter` resolved the leaf container's validator directly from the registry (by `ModelMetadata.ContainerType`), so a nested `NotEmpty()` marked the flattened parameter (e.g. `RequiredSubType.SubProperty`) as `required` even though FluentValidation never validates an unwired child object — the OpenAPI doc claimed `required`, but the API accepted requests without it
- Fix: for a flattened nested parameter, nested rules are now applied only when the `SetValidator`/`ChildRules` chain from the action's root `[FromQuery]` validator actually reaches the leaf container; otherwise the parameter is left unconstrained, matching runtime behavior
- When the root container type cannot be resolved, prior behavior is preserved (no regression for existing nested-parameter scenarios)
- Behavioral change: when no validator is registered for the root `[FromQuery]` type (only a leaf/child validator is registered), a flattened nested parameter is now left unconstrained — matching runtime, where no validation runs without a root validator
- Fixed: A required leaf property inside an **optional** nested type bound via `[FromQuery]` was wrongly marked as a required parameter (Issue #209)
- The 7.1.1 fix (Issue #162) made nested `[FromQuery]` validation match the leaf property name, but `FluentValidationOperationFilter` then set `required` based solely on the leaf type, ignoring whether the ancestor segment of the dot-path was optional
- Because two nested properties of the same leaf type share one schema/validator (e.g. `OptionalSubType.SubProperty` and `RequiredSubType.SubProperty`), a `NotEmpty()` on the leaf marked **both** flattened parameters as required
- Fix: a flattened nested parameter is now marked `required` only when **every** ancestor segment of the dot-path is required — resolved from the action's root `[FromQuery]` type, combining the native schema `required` (e.g. the C# `required` modifier) with FluentValidation `NotNull`/`NotEmpty` rules
- Value constraints (e.g. `minLength`) still apply to an optional nested parameter when it is provided
- When the root container type cannot be resolved, prior behavior is preserved (no regression for existing nested-parameter scenarios)
# Changes in 7.1.6
- Fixed: `$ref` still replaced with an inline copy (and the child component left orphaned) when nested object constraints come from `ChildRules` or an inline child validator (Issue #198, comment 4601720562)
- The 7.1.3 fix restored unmodified `$ref`s, but when the nested type had no standalone validator its component schema gained its `Required` only after the parent's inline snapshot, so the stale `Required` diverged and defeated the restore check — leaving an inline copy and an orphaned component
- Fix: the `Required` comparison in `HasValidationConstraintChanges` is now directional — restoration is only blocked when the inline copy carries a required entry the component lacks
- `SetValidator` (with a standalone child validator) was already correct; `BigInteger`/enum per-model constraints (Issues #146/#176) continue to work
- Added: `ConditionalRulesMode` option to control how `.When()`/`.Unless()` conditional rules are handled during schema generation (Issue #203)
- `Exclude` (default): conditional rules are excluded from the schema (backward-compatible, existing behavior)
- `Include`: conditional rules are included in the schema (useful when `.When()` is a null-guard and constraints should still appear)
- `IncludeWithWarning`: same as `Include` but logs a warning for each conditional rule included
- Usage: `options.ConditionalRules = ConditionalRulesMode.Include;`
- Fixed: Multiple `.Matches()` rules on one property displayed incorrectly — only the first pattern shown, property duplicated (Issue #204)
- Multiple patterns were placed into separate `allOf` subschemas, which Swagger UI/Redoc/Scalar collapse, keeping only the first `pattern`
- Now multiple `.Matches()` rules are combined into a single `pattern` via lookahead assertions (e.g. `(?=[\s\S]*(?:[a-z]))(?=[\s\S]*(?:[A-Z]))`), preserving `.Matches()` semantics and rendering correctly
- Applied to all providers: Swashbuckle, `MicroElements.AspNetCore.OpenApi.FluentValidation`, and NSwag (NSwag previously kept only the last pattern)
- Changed: `SchemaGenerationOptions.UseAllOfForMultipleRules` default `true` → `false`; set it to `true` to keep the legacy `allOf` representation
# Changes in 7.1.4
- Added: `FluentValidationOperationTransformer` (`IOpenApiOperationTransformer`) for `MicroElements.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()`
- Fixed: Nested DTOs in request body not receiving validation constraints (Issue #200)
- `FluentValidationSchemaTransformer` skipped 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
# Changes in 7.1.3
- Fixed: `$ref` replaced with inline schema copy when using `SetValidator` with nested object types (Issue #198)
- `ResolveRefProperty` (introduced in 7.1.2 for BigInteger isolation) replaced all `$ref` properties with copies, destroying reference structure in the OpenAPI document
- Fix: snapshot `$ref` properties 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 release notes can be found at: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/blob/master/CHANGELOG.md