Fluent.Unions.OpenApi
1.1.0
dotnet add package Fluent.Unions.OpenApi --version 1.1.0
NuGet\Install-Package Fluent.Unions.OpenApi -Version 1.1.0
<PackageReference Include="Fluent.Unions.OpenApi" Version="1.1.0" />
<PackageVersion Include="Fluent.Unions.OpenApi" Version="1.1.0" />
<PackageReference Include="Fluent.Unions.OpenApi" />
paket add Fluent.Unions.OpenApi --version 1.1.0
#r "nuget: Fluent.Unions.OpenApi, 1.1.0"
#:package Fluent.Unions.OpenApi@1.1.0
#addin nuget:?package=Fluent.Unions.OpenApi&version=1.1.0
#tool nuget:?package=Fluent.Unions.OpenApi&version=1.1.0
![]()
Fluent.Unions.OpenApi
Describes Option<T> as a nullable T in the documents that Microsoft.AspNetCore.OpenApi 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.OpenApi
Usage
Register the schema transformer. Without it, an option is an object without a type.
using Fluent.Unions.OpenApi;
builder.Services.AddOpenApi(options => options.AddFluentUnions());
app.MapOpenApi();
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);
// "nickname": type ["null", "string"], "stock": type ["null", "integer", "string"] with format int32
An option property stays in required, because it is always written, as null for none. For Swashbuckle and NSwag, use Fluent.Unions.Swashbuckle and Fluent.Unions.NSwag.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Fluent.Unions (>= 1.1.0)
- Microsoft.AspNetCore.OpenApi (>= 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.