NativeOpenApi 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NativeOpenApi --version 1.2.1
                    
NuGet\Install-Package NativeOpenApi -Version 1.2.1
                    
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="NativeOpenApi" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NativeOpenApi" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="NativeOpenApi" />
                    
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 NativeOpenApi --version 1.2.1
                    
#r "nuget: NativeOpenApi, 1.2.1"
                    
#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 NativeOpenApi@1.2.1
                    
#: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=NativeOpenApi&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=NativeOpenApi&version=1.2.1
                    
Install as a Cake Tool

Native.OpenApi

Build Status License: MIT

A collection of .NET libraries for OpenAPI 3.1 document management, optimized for Native AOT applications.

Packages

Package NuGet Description
NativeOpenApi NuGet OpenAPI document loading, linting, merging, and HTML rendering
NativeOpenApiGenerator NuGet Source Generator for automatic OpenAPI spec generation

Overview

NativeOpenApi

Core library for working with OpenAPI 3.1 documents in Native AOT applications.

Features:

  • 📄 Load OpenAPI specs from embedded resources (JSON and YAML)
  • 🔀 Merge multiple partial specs into a consolidated document
  • ✅ Lint and validate documents against configurable rules
  • 📖 Generate Redoc and Scalar documentation pages
  • ⚡ Full Native AOT compatibility
dotnet add package NativeOpenApi
var resourceReader = new OpenApiResourceReader(typeof(Program).Assembly, "MyApp.");
var loader = new MyOpenApiDocumentLoader(resourceReader);
var merger = new MyOpenApiDocumentMerger();
var linter = new OpenApiLinter(OpenApiLintOptions.Empty);
var provider = new OpenApiDocumentProvider(loader, merger, linter);

provider.WarmUp();
var json = provider.Document.Json;

👉 Full documentation


NativeOpenApiGenerator

Roslyn Source Generator that automatically creates OpenAPI specifications from NativeLambdaRouter endpoints at compile time.

Features:

  • 🔧 Compile-time generation (zero runtime overhead)
  • 🔍 Automatic endpoint discovery from MapGet, MapPost, etc.
  • 📝 Generates OpenAPI 3.1 compliant YAML
  • 🏷️ Auto-generates operation IDs, tags, and security definitions
dotnet add package NativeOpenApiGenerator
// Endpoints are discovered automatically at build time
routes.MapGet<GetItemsCommand, GetItemsResponse>("/v1/items", ctx => new GetItemsCommand());
routes.MapPost<CreateItemCommand, CreateItemResponse>("/v1/items", ctx => Deserialize<CreateItemCommand>(ctx.Body!));

// Access the generated spec
string yaml = Native.OpenApi.Generated.GeneratedOpenApiSpec.Yaml;

👉 Full documentation


Quick Start

Option 1: Document Loading & Merging Only

Use NativeOpenApi to load, merge, and serve your manually-written OpenAPI specs:

dotnet add package NativeOpenApi

Option 2: Automatic Generation + Loading

Use both packages together for automatic endpoint discovery combined with document management:

dotnet add package NativeOpenApi
dotnet add package NativeOpenApiGenerator
// Generated spec from your endpoints
var generatedYaml = Native.OpenApi.Generated.GeneratedOpenApiSpec.Yaml;

// Merge with common schemas and render documentation
var provider = new OpenApiDocumentProvider(loader, merger, linter);
var html = renderer.RenderRedoc("/openapi/v1/spec.json", "My API");

Project Structure

native-open-api/
├── src/
│   ├── Native.OpenApi/           # Core library
│   │   ├── OpenApiDocumentLoader.cs
│   │   ├── OpenApiDocumentMerger.cs
│   │   ├── OpenApiDocumentProvider.cs
│   │   ├── OpenApiLinter.cs
│   │   ├── OpenApiHtmlRenderer.cs
│   │   └── README.md
│   │
│   └── Native.OpenApi.Generator/ # Source Generator
│       ├── OpenApiSourceGenerator.cs
│       ├── OpenApiYamlGenerator.cs
│       └── README.md
│
└── tests/
    ├── Native.OpenApi.Tests/
    └── Native.OpenApi.Generator.Tests/

Requirements

  • .NET 10.0 or later
  • C# 12.0 or later

Building from Source

git clone https://github.com/swepay/native-open-api.git
cd native-open-api
dotnet build
dotnet test

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

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.

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.6.0 230 2/23/2026
1.5.1 168 2/19/2026
1.5.0 94 2/18/2026
1.4.1 84 2/18/2026
1.4.0 47 2/17/2026
1.3.3 117 2/13/2026
1.3.1 107 2/11/2026
1.3.0 55 2/11/2026
1.2.6 54 2/11/2026
1.2.5 53 2/11/2026
1.2.4 55 2/11/2026
1.2.3 57 2/9/2026
1.2.2 53 2/3/2026
1.2.1 58 2/3/2026
1.2.0 55 2/3/2026
1.1.0 60 2/2/2026
1.0.0 145 2/1/2026