Skip to content

Releases: micro-elements/MicroElements.Swashbuckle.FluentValidation

7.1.5-beta.2

16 May 12:18

Choose a tag to compare

7.1.5-beta.2 Pre-release
Pre-release

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 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, preserving .Matches() semantics and rendering correctly.
    • Applied to all providers: Swashbuckle, MicroElements.AspNetCore.OpenApi.FluentValidation, and NSwag.
    • Behavior change: SchemaGenerationOptions.UseAllOfForMultipleRules default truefalse; set it to true to keep the legacy allOf representation.

Already in 7.1.5-beta

  • Added: ConditionalRulesMode option to control how .When()/.Unless() conditional rules are handled during schema generation (#203).

See CHANGELOG.md for full details.

v7.1.5-beta

01 Apr 12:05

Choose a tag to compare

v7.1.5-beta Pre-release
Pre-release

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 schema
  • IncludeWithWarning — 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

29 Mar 16:06
a420117

Choose a tag to compare

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

v7.1.4-beta

24 Mar 12:18
8358cd9

Choose a tag to compare

v7.1.4-beta Pre-release
Pre-release

Changes in 7.1.4-beta

  • 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

Full Changelog: v7.1.3...v7.1.4-beta

v7.1.3

24 Mar 07:59
db4beb7

Choose a tag to compare

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 Changelog: v7.1.2...v7.1.3

v7.1.2

09 Mar 21:49
29a50d3

Choose a tag to compare

Changes in 7.1.2

  • Added: BigInteger support for min/max validation constraints in OpenAPI schema generation (Issue #146)
    • IsNumeric() and NumericToDecimal() now handle BigInteger values
    • BigInteger properties with GreaterThan, LessThan, InclusiveBetween, ExclusiveBetween rules produce correct minimum/maximum in Swagger
    • NSwag provider updated with the same BigInteger support
    • Out-of-range BigInteger values (exceeding decimal range) are handled gracefully via existing try/catch
  • Fixed: Shared schema mutation when multiple models reference the same BigInteger type with different constraints (net10.0)
    • ResolveRefProperty creates an isolated shallow copy before applying rule mutations
    • Prevents $ref-based schema corruption across models in SchemaRepository
  • Fixed: Replaced deprecated PackageLicenseUrl with PackageLicenseExpression (Issue #144)
  • Fixed: Replaced deprecated PackageIconUrl with embedded PackageIcon

v7.1.1

09 Mar 17:30
18c8bcc

Choose a tag to compare

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 both FluentValidationOperationFilter and FluentValidationDocumentFilter
    • Supports arbitrarily deep nesting (e.g., a.b.cc)
  • Added: SetNotNullableIfMinimumGreaterThenZero option 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)
  • Fixed: SetNotNullableIfMinLengthGreaterThenZero option now works in NSwag provider (Issue #154)
    • NSwagFluentValidationRuleProvider now accepts IOptions<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

09 Mar 17:29
dd76c87

Choose a tag to compare

Changes in 7.1.0

  • Added: New package MicroElements.AspNetCore.OpenApi.FluentValidation for Microsoft.AspNetCore.OpenApi support (Issue #149)
    • Implements IOpenApiSchemaTransformer for .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)
  • Fixed: AspNetCore.OpenApi.FluentValidation support for .NET 10 (Issue #149, PR #192)
  • Added: Sample project SampleAspNetCoreOpenApi demonstrating Microsoft.AspNetCore.OpenApi integration
  • Added: ADR-001 documenting the architectural decision for AspNetCore.OpenApi support

v7.1.0-beta.2

06 Mar 08:25
15353e5

Choose a tag to compare

v7.1.0-beta.2 Pre-release
Pre-release

Changes in 7.1.0-beta.2

AspNetCore.OpenApi.FluentValidation — .NET 10 fix (Issue #149)

  • Fix: Scoped → Transient DI registration for FluentValidationSchemaTransformer and IValidatorRegistry — .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.0 with enum property test
  • Update: ADR-001 with post-beta findings

Swashbuckle — merged from v7.0.5 / v7.0.6

  • Add: RemoveUnusedQuerySchemas option to control schema cleanup (Issue #180)
  • Fix: [AsParameters] validation rules not applied on .NET 8 — ContainerType null 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

03 Mar 13:50

Choose a tag to compare

Changes in 7.0.6

  • Fixed: [AsParameters] validation rules not applied on .NET 8 Minimal APIs (Issue #180)
    • On .NET 8, ModelMetadata.ContainerType is null for [AsParameters] decomposed parameters
    • Added AsParametersHelper fallback that resolves the container type via [AsParameters] reflection on MethodInfo
    • Applied fallback in both FluentValidationOperationFilter and FluentValidationDocumentFilter
    • Zero regression on .NET 9/10 where ContainerType is already populated

Full Changelog: v7.0.5...v7.0.6