Back to Aspnetcore

Openapi Aot

aspnetcore/release-notes/aspnetcore-9/includes/openapi-aot.md

latest618 B
Original Source

Microsoft.AspNetCore.OpenApi supports trimming and Native AOT

OpenAPI in ASP.NET Core supports trimming and native AOT. The following steps create and publish an OpenAPI app with trimming and native AOT:

Create a new ASP.NET Core Web API (Native AOT) project.

console
dotnet new webapiaot

Add the Microsoft.AspNetCore.OpenAPI package.

console
dotnet add package Microsoft.AspNetCore.OpenApi

Update Program.cs to enable generating OpenAPI documents.

diff
+ builder.Services.AddOpenApi();

var app = builder.Build();

+ app.MapOpenApi();

Publish the app.

console
dotnet publish