Kalicz.StrongTypes.OpenApi.Microsoft
1.1.0
dotnet add package Kalicz.StrongTypes.OpenApi.Microsoft --version 1.1.0
NuGet\Install-Package Kalicz.StrongTypes.OpenApi.Microsoft -Version 1.1.0
<PackageReference Include="Kalicz.StrongTypes.OpenApi.Microsoft" Version="1.1.0" />
<PackageVersion Include="Kalicz.StrongTypes.OpenApi.Microsoft" Version="1.1.0" />
<PackageReference Include="Kalicz.StrongTypes.OpenApi.Microsoft" />
paket add Kalicz.StrongTypes.OpenApi.Microsoft --version 1.1.0
#r "nuget: Kalicz.StrongTypes.OpenApi.Microsoft, 1.1.0"
#:package Kalicz.StrongTypes.OpenApi.Microsoft@1.1.0
#addin nuget:?package=Kalicz.StrongTypes.OpenApi.Microsoft&version=1.1.0
#tool nuget:?package=Kalicz.StrongTypes.OpenApi.Microsoft&version=1.1.0
Kalicz.StrongTypes.OpenApi.Microsoft
OpenAPI schema plumbing for Kalicz.StrongTypes.
Out of the box Microsoft.AspNetCore.OpenApi 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 transformers that rewrite those
schemas to match the JSON the converters actually emit, so generated clients
and API explorers see the real wire format.
If your app uses Swashbuckle (AddSwaggerGen()) instead, install
Kalicz.StrongTypes.OpenApi.Swashbuckle
— it provides the same schema corrections against Swashbuckle's pipeline.
Install
dotnet add package Kalicz.StrongTypes.OpenApi.Microsoft
Register
builder.Services.AddOpenApi(options => options.AddStrongTypes());
var app = builder.Build();
app.MapOpenApi();
What it does
NonEmptyString→{ "type": "string", "minLength": 1 }Positive<T>→ underlying primitive withexclusiveMinimum: 0NonNegative<T>→ underlying primitive withminimum: 0Negative<T>→ underlying primitive withexclusiveMaximum: 0NonPositive<T>→ underlying primitive withmaximum: 0NonEmptyEnumerable<T>andINonEmptyEnumerable<T>→{ "type": "array", "minItems": 1, "items": <T schema> }Maybe<T>→ object wrapper{ "Value": <T schema, nullable> }matching the converter's on-the-wire format.
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
Microsoft.AspNetCore.OpenApi natively supports on a primitive-typed
property also works on 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,
[Url]
NonEmptyString Website,
[Description("Short user tagline")]
NonEmptyString Tagline);
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 } } |
Website |
{ "type": "string", "minLength": 1, "format": "uri" } |
Tagline |
{ "type": "string", "minLength": 1, "description": "Short user tagline" } |
A few attributes are intentionally not propagated because the underlying pipeline doesn't honor them on a primitive-typed property either, and the wrapper-typed surface stays consistent with the primitive-typed surface on each pipeline:
[EmailAddress]—Microsoft.AspNetCore.OpenApidoesn't writeformat: "email"for it. The Swashbuckle adapter does propagate it (because Swashbuckle'sDataAnnotationsSchemaFilterdoes).[DefaultValue]— the framework's own default-value handler crashes when the attribute's underlying value (e.g.string) doesn't match the property's declared wrapper type (e.g.NonEmptyString). Apply[DefaultValue]only to primitive-typed properties.
| Product | Versions 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. |
-
net10.0
- Kalicz.StrongTypes (>= 1.1.0)
- Microsoft.AspNetCore.OpenApi (>= 10.0.0 && < 11.0.0)
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 |
|---|---|---|
| 1.1.0 | 90 | 5/5/2026 |