OpenAPI
SuperStrong.Types integrates with the built-in OpenAPI support in ASP.NET Core. Strong types are represented in the generated document by their underlying primitive, either inline or as a named component.
Requirements
This integration targets ASP.NET Core 10, so make sure your project uses it.
Installation
First, install the package from NuGet:
dotnet add package SuperStrong.Types.AspNetCore.OpenApi --version 1.0.0-beta.5<PackageReference Include="SuperStrong.Types.AspNetCore.OpenApi" Version="1.0.0-beta.5" />Setup
To enable the integration, call AddStrongTypes(...) when configuring OpenAPI. The representation is required, so the choice is always explicit:
builder.Services.AddOpenApi(options =>
options.AddStrongTypes(StrongTypeOpenApiRepresentation.Reference));Representation
A strong type can be represented in two ways. Pick the one that fits your frontend.
Inline replaces the strong type with its underlying primitive everywhere it is used (properties, collection elements, dictionary keys and values, parameters, and any nesting of those):
{ "type": "string", "format": "uuid" }The generated client sees a plain primitive. This is the safe choice when the frontend isn't ready for distinct types.
Reference emits a named schema component and references it everywhere the strong type is used:
{ "$ref": "#/components/schemas/UserId" }Client code generation can turn it into a distinct type, so strong typing carries over to the frontend.
