MinimalOpenAPI 1.1.0

dotnet add package MinimalOpenAPI --version 1.1.0
                    
NuGet\Install-Package MinimalOpenAPI -Version 1.1.0
                    
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="MinimalOpenAPI" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MinimalOpenAPI" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MinimalOpenAPI" />
                    
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 MinimalOpenAPI --version 1.1.0
                    
#r "nuget: MinimalOpenAPI, 1.1.0"
                    
#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 MinimalOpenAPI@1.1.0
                    
#: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=MinimalOpenAPI&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MinimalOpenAPI&version=1.1.0
                    
Install as a Cake Tool

MinimalOpenAPI

MinimalOpenAPI is a contract-first OpenAPI framework for ASP.NET Core Minimal APIs.

You author an OpenAPI 3.0 or 3.1 document in YAML or JSON. At build time, MinimalOpenAPI generates the C# contracts, handler base classes, dependency-injection registration, and endpoint mapping required to implement the API.

Requirements

  • .NET 10
  • ASP.NET Core

Minimal setup

<ItemGroup>
  <PackageReference Include="MinimalOpenAPI" Version="1.0.0" />
  <OpenApi Include="openapi.yaml" />
</ItemGroup>
using MinimalOpenAPI;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMinimalOpenApi();

var app = builder.Build();
app.MapMinimalOpenApiEndpoints();
app.Run();

Implement the generated <OperationId>EndpointBase class for each operation. No manual route or handler registration is required.

What the package includes

  • Roslyn incremental source generator
  • ASP.NET Core runtime services
  • YAML and JSON OpenAPI parsers
  • contract records and enums
  • typed handler signatures and results
  • abstract endpoint configuration base classes applied after contract metadata
  • authored-schema publishing support

MinimalOpenAPI is the only package consumers need. Parser and abstraction assemblies are bundled as implementation details.

Selected features

  • OpenAPI 3.0 and 3.1
  • YAML and JSON documents
  • multiple documents per project
  • component and inline object schemas
  • inline objects used as array items
  • enums, dictionaries, validation metadata, and allOf flattening
  • readOnly and writeOnly request/response contract splitting
  • path, query, header, reusable, and path-level parameters
  • parameter default values
  • typed results and application/problem+json wrappers
  • handler response filtering through ExcludeStatusCodesFromHandlers and per-operation MinimalOpenApiHandler include/exclude overrides
  • recursively nested ASP.NET Core Results<> unions for more than six distinct effective handler result types
  • diagnostics MOA015–MOA017 for invalid handler responses, duplicate operation IDs, and unresolved or unsupported schema references
  • multipart/form-data, IFormFile, multiple files, and nested form objects
  • deterministic schema-name normalization with compile-time collision diagnostics
  • explicit schema publication through PublishAs and MapOpenApiSchemas()

Directional contracts

<OpenApi Include="openapi.yaml"
         ReadWriteSchemaHandling="Auto" />
  • Ignore keeps neutral contracts.
  • Auto creates request/response variants only when reachable readOnly or writeOnly properties require different shapes.
  • Split always generates request and response graphs from operation body roots.

Publishing authored schemas

<OpenApi Include="openapi.yaml"
         PublishAs="/openapi/schema.yaml"
         DisplayName="Todo API"
         DisplayVersion="1.0.0" />
app.MapMinimalOpenApiEndpoints();
var schemas = app.MapOpenApiSchemas();

The returned descriptors can be used to configure Swagger UI, Scalar, or another OpenAPI viewer. MinimalOpenAPI serves the authored document; it does not generate a second document from C# at runtime.

Handler response filtering

Configuration is layered: <OpenApi> sets document-level generation options, <MinimalOpenApiHandler> sets generated handler responses for one operation, and EndpointConfigurationBase provides runtime endpoint customization.

The handler item's Include is the OpenAPI operationId:

<ItemGroup>
  <OpenApi Include="openapi.yaml" ExcludeStatusCodesFromHandlers="401;403" />
  <MinimalOpenApiHandler Include="getOrder"
                         IncludeStatusCodes="403" ExcludeStatusCodes="409" />
</ItemGroup>

For multiple documents, OpenApiFile identifies the configured <OpenApi> item path; basenames do not match paths in other directories:

<MinimalOpenApiHandler Include="getOrder"
                       OpenApiFile="contracts/orders/openapi.yaml"
                       ExcludeStatusCodes="409" />

OpenApiFile is optional with exactly one document and required with multiple documents. An explicitly supplied path is always validated. Global exclusions are applied before handler includes and excludes, with excludes taking precedence. Status codes must be declared by the selected operation. Filtering changes handler result types only; declared responses remain in endpoint metadata.

More documentation

Full documentation, samples, limitations, architecture notes, and release guidance are available in the repository:

https://github.com/Kralizek/MinimalOpenApi

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.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.

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 206 10/3/2026
1.0.0 215 7/15/2026
1.0.0-rc.4 88 7/15/2026
1.0.0-rc.3 98 7/14/2026
1.0.0-rc.2 117 6/22/2026
1.0.0-rc.1 98 5/25/2026
1.0.0-beta.11 93 5/20/2026
1.0.0-beta.10 94 5/11/2026
1.0.0-beta.9 99 5/9/2026
1.0.0-beta.8 98 4/18/2026
1.0.0-beta.7 89 4/7/2026
1.0.0-beta.6 87 4/6/2026
1.0.0-beta.5 87 4/5/2026
1.0.0-beta.4 89 4/5/2026
1.0.0-beta.3 89 4/5/2026
1.0.0-beta.2 92 4/4/2026
1.0.0-alpha 124 3/30/2026