Fluent.Unions.Swashbuckle
1.1.0
dotnet add package Fluent.Unions.Swashbuckle --version 1.1.0
NuGet\Install-Package Fluent.Unions.Swashbuckle -Version 1.1.0
<PackageReference Include="Fluent.Unions.Swashbuckle" Version="1.1.0" />
<PackageVersion Include="Fluent.Unions.Swashbuckle" Version="1.1.0" />
<PackageReference Include="Fluent.Unions.Swashbuckle" />
paket add Fluent.Unions.Swashbuckle --version 1.1.0
#r "nuget: Fluent.Unions.Swashbuckle, 1.1.0"
#:package Fluent.Unions.Swashbuckle@1.1.0
#addin nuget:?package=Fluent.Unions.Swashbuckle&version=1.1.0
#tool nuget:?package=Fluent.Unions.Swashbuckle&version=1.1.0
![]()
Fluent.Unions.Swashbuckle
Describes Option<T> as a nullable T in the documents that Swashbuckle.AspNetCore generates. It builds on Fluent.Unions and matches the JSON shape of an option: the value, or null for none.
Installation
dotnet add package Fluent.Unions.Swashbuckle
Usage
Register the schema filter. Without it, an option is not described as a nullable type.
using Fluent.Unions.Swashbuckle;
builder.Services.AddSwaggerGen(options => options.AddFluentUnions());
Options in a request or response body then become nullable types, so generated clients see them.
public record Product(string Name, Option<string> Nickname, Option<int> Stock, Option<Address> Shipping);
// "nickname": string, nullable; "stock": integer int32, nullable; "shipping": null or Address
A plain T (primitives, arrays, lists) gets nullable in an OpenAPI 3.0 document and null in the type in a 3.1 document. A T that Swashbuckle describes through a reference (records, enums, nested options) becomes a oneOf of null and that reference. An option property is not required, as for any value type in Swashbuckle.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Fluent.Unions (>= 1.1.0)
- Swashbuckle.AspNetCore.SwaggerGen (>= 11.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.