Skip to content

Releases: micro-elements/MicroElements.Swashbuckle.FluentValidation

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

v7.0.5

26 Feb 20:27

Choose a tag to compare

Changes in 7.0.5

  • Added: RemoveUnusedQuerySchemas option (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

23 Feb 11:55
2bca958

Choose a tag to compare

7.1.0-beta.1 Pre-release
Pre-release

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 IOpenApiSchemaTransformer for seamless integration with Microsoft.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

17 Feb 17:07
09b6012

Choose a tag to compare

Changes in 7.0.4

  • Fixed: [AsParameters] types in minimal API and [FromQuery] container types create unused schemas in components/schemas (Issue #180)
  • Added: Support for keyed DI services (Issue #165)
    • Validators registered via AddKeyedScoped, AddKeyedTransient, AddKeyedSingleton are now discovered automatically
  • Removed: Deprecated FluentValidation.AspNetCore package reference (Issue #164)
    • Replaced with FluentValidation.DependencyInjectionExtensions 12.0.0