Kalicz.StrongTypes.OpenApi.Swashbuckle 2.0.1

dotnet add package Kalicz.StrongTypes.OpenApi.Swashbuckle --version 2.0.1
                    
NuGet\Install-Package Kalicz.StrongTypes.OpenApi.Swashbuckle -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kalicz.StrongTypes.OpenApi.Swashbuckle" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kalicz.StrongTypes.OpenApi.Swashbuckle" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Kalicz.StrongTypes.OpenApi.Swashbuckle" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kalicz.StrongTypes.OpenApi.Swashbuckle --version 2.0.1
                    
#r "nuget: Kalicz.StrongTypes.OpenApi.Swashbuckle, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kalicz.StrongTypes.OpenApi.Swashbuckle@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kalicz.StrongTypes.OpenApi.Swashbuckle&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Kalicz.StrongTypes.OpenApi.Swashbuckle&version=2.0.1
                    
Install as a Cake Tool

Kalicz.StrongTypes.OpenApi.Swashbuckle

NuGet version Downloads License

Swashbuckle (Swagger) schema plumbing for Kalicz.StrongTypes.

Out of the box Swashbuckle.AspNetCore describes the raw CLR shape of strong types — so a NonEmptyString property shows up as a class with a Value field, Positive<int> as a wrapper object, and Maybe<T> as the full union surface. This package registers schema filters that rewrite those schemas to match the JSON the converters actually emit, so generated clients and Swagger UI see the real wire format.

If your app uses Microsoft.AspNetCore.OpenApi (AddOpenApi()) instead of Swashbuckle, install Kalicz.StrongTypes.OpenApi.Microsoft — it provides the same schema corrections against Microsoft's pipeline.

Install

dotnet add package Kalicz.StrongTypes.OpenApi.Swashbuckle

Register

builder.Services.AddSwaggerGen(options => options.AddStrongTypes());

var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();

What it does

  • NonEmptyString → { "type": "string", "minLength": 1 }
  • Email → { "type": "string", "format": "email", "minLength": 1, "maxLength": 254 }
  • Digit → { "type": "integer", "format": "int32", "minimum": 0, "maximum": 9 }
  • Positive<T> → underlying primitive with minimum: 0, exclusiveMinimum: true
  • NonNegative<T> → underlying primitive with minimum: 0
  • Negative<T> → underlying primitive with maximum: 0, exclusiveMaximum: true
  • NonPositive<T> → underlying primitive with maximum: 0
  • NonEmptyEnumerable<T> and INonEmptyEnumerable<T> → { "type": "array", "minItems": 1, "items": <T schema> }
  • Maybe<T> → object wrapper { "Value": <T schema> } matching the converter's on-the-wire format.
  • FiniteInterval<T> / Interval<T> / IntervalFrom<T> / IntervalUntil<T> → { "type": "object", "properties": { "Start": <T>, "End": <T>, "StartInclusive": bool, "EndInclusive": bool }, "required": ["Start", "End"] }, a bounded endpoint non-nullable and an open one nullable. The two inclusivity flags are optional booleans; the schema pins no default, since an omitted flag's inclusivity is the applied converter's choice.

Data annotations

Both ASP.NET Core OpenAPI pipelines drop every ValidationAttribute on a property whose CLR type carries a custom JsonConverter — which every strong-type wrapper does — collapsing the property to a bare $ref to the wrapper component.

This package re-applies them: every annotation Swashbuckle's DataAnnotationsSchemaFilter natively writes for a primitive-typed property (including any third-party schema filter you've registered) also reaches a wrapper-typed one. Caller bounds compose with the wrapper's floor under tighter-wins rules: the wrapper never relaxes a caller's constraint, and a caller bound that would loosen the wrapper's floor is ignored.

public sealed record CreateUserRequest(
    [StringLength(50, MinimumLength = 3)]
    [RegularExpression("^[a-zA-Z0-9_]+$")]
    NonEmptyString Username,

    [Range(18, 120)]
    Positive<int> Age,

    [MaxLength(10)]
    NonEmptyEnumerable<NonEmptyString> Tags,

    [EmailAddress]
    NonEmptyString ContactEmail,

    [Url]
    NonEmptyString Website);

On the wire:

Property Resulting schema
Username { "type": "string", "minLength": 3, "maxLength": 50, "pattern": "^[a-zA-Z0-9_]+$" }
Age { "type": "integer", "format": "int32", "minimum": 18, "maximum": 120 }
Tags { "type": "array", "minItems": 1, "maxItems": 10, "items": { "type": "string", "minLength": 1 } }
ContactEmail { "type": "string", "minLength": 1, "format": "email" }
Website { "type": "string", "minLength": 1, "format": "uri" }

Annotations Swashbuckle's filter doesn't natively map on primitive-typed properties — e.g. [Description], [DefaultValue], [Length], [Base64String] — aren't written here either, so the wrapper-typed surface stays consistent with the primitive-typed one. If you also need those, install Kalicz.StrongTypes.OpenApi.Microsoft and use Microsoft.AspNetCore.OpenApi.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 354 7/17/2026
2.0.0 146 7/16/2026
1.2.0 183 7/12/2026
1.1.1 229 6/24/2026
1.1.0 564 5/5/2026