An OpenAPI Document on Every ASP.NET Core Build
· The Routebase Team

Your ASP.NET Core API already knows everything its docs need. Every route, every parameter and every response type is in the code, so getting docs shouldn't take a separate tool, a hand-written page or an afternoon of setup.
With Routebase.AspNetCore 1.0, it takes one package, one line in Program.cs
and one build. This post shows those three steps first, and then the JSON and
YAML documents that the build writes. After that, you'll see what makes the
descriptions clean, what's worth knowing before you ship, and what Routebase
adds when you sign up.
Docs in three steps
Start with any ASP.NET Core API that uses OpenAPI. A new project from the
webapi template already does, because it registers
builder.Services.AddOpenApi().
1. Add the package.
dotnet add package Routebase.AspNetCore2. Add one line to Program.cs, right after var app = builder.Build();.
using Routebase.AspNetCore;
var app = builder.Build();
app.MapRoutebaseApiReference();3. Run your app.
dotnet runOpen /routebase on the address your app prints, and your docs are there.

The page lists your endpoints by tag, with a search and code samples for each one. Its playground sends requests to your API straight from the browser, and Copy as Markdown hands an endpoint to an AI assistant with its parameters, request body and responses. You can also download the document as JSON, as YAML or as a Postman collection, and every schema has a page of its own.

Behind the page, every build now writes your OpenAPI document as JSON and as YAML, and the docs read that file. So they show exactly the build you deployed, and they work in production without a runtime document route.
Generate OpenAPI JSON and YAML at build time
Those two files are useful on their own. After dotnet build, your OpenAPI
document sits in the obj folder as JSON and as YAML, for example
obj/OrdersApi.json and obj/OrdersApi.yaml, and you can hand either one to
any tool that reads OpenAPI.
The YAML file is the one you don't get from ASP.NET Core alone. The build-time generation that ships with it writes JSON only. Microsoft's documentation, last updated in November 2026, says that YAML at build time "isn't supported but planned for a future preview".
With Routebase.AspNetCore, you don't wait for that preview and you don't maintain a conversion step. Every build writes a YAML copy next to the JSON document, and the copy holds the same document key for key and in the same order.
Clean descriptions
The docs can only be as good as what your code declares. Three things turn a list of routes into a reference that people can actually work with.
Say what each endpoint does
Give each endpoint a tag, a summary and a description. The tag groups the endpoint in the navigation, and the summary and the description tell the reader what it does and when to use it.
app.MapGet("/products/{id:int}", GetProduct)
.WithTags("Products")
.WithSummary("Get a product")
.WithDescription("Returns one product by its ID, or 404 when no product has that ID.");Let every response show up
A handler that returns Results.Ok(product) hides the type from the OpenAPI
generator, which would document a bare 200 without a body and skip the 404. The
package reads such handlers while your app compiles and adds the responses for
you. So the endpoint below shows a 200 with Product and a 404 with ApiError,
and you don't change a line.
app.MapGet("/products/{id:int}", (int id, DataStore db) =>
db.Products.FirstOrDefault(p => p.Id == id) is { } product
? Results.Ok(product)
: Results.NotFound(new ApiError("NOT_FOUND", "Product not found.")));Where the build can't read a handler, for example because one path returns an
anonymous object, your editor marks it and offers a fix. One click switches the
handler to TypedResults or turns the anonymous object into a record, and the
JSON your clients get stays the same. Controllers get the same help, where the
fix adds the missing [ProducesResponseType] attributes.

Describe your models
Your schemas take their descriptions from the XML comments you may already write. Switch on the documentation file in the project file, and the second line keeps the compiler from asking for a comment on every public member.
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>/// <summary>A product in the catalog.</summary>
/// <param name="Id">The product ID.</param>
/// <param name="Name">The name shown in the shop.</param>
public record Product(int Id, string Name);Good to know before you ship
The build starts your app. To read your endpoints, the build runs
Program.cs in the Production environment without its runtime configuration.
A registration that needs a connection string or a secret fails there, so skip
it while the document is written.
if (!RoutebaseOpenApi.IsGeneratingDocument)
{
builder.Services.AddSingleton(new PaymentClient(builder.Configuration["Payments:ApiKey"]!));
}The document can live in your repository. The files start out in obj/,
which nobody commits. Set the folder in the project file, and every API change
shows up in the diff of the pull request that made it.
<PropertyGroup>
<OpenApiDocumentsDirectory>$(MSBuildProjectDirectory)/openapi</OpenApiDocumentsDirectory>
</PropertyGroup>
You decide who sees the docs. The page works in production, so map it
inside if (app.Environment.IsDevelopment()) to keep it on your machine, or
protect it with .RequireAuthorization() like any other endpoint.
Your generator stays. The package works with Microsoft.AspNetCore.OpenApi, Swashbuckle and NSwag, and the build-time generation it brings along adds nothing to the output of your app.
What Routebase adds
Up to here, everything runs on your machine without an account. Routebase takes the same document further, and you start right from your docs page.
One click from localhost
While your docs run on localhost, their header carries the menu Open in
Routebase. Each action opens a Routebase tab and takes your document along:
- Rate and lint grades the design of your API and checks it against your organization's style guide.
- Mock server starts a stand-in for your API that answers from the document, so a frontend can build against it before the backend is done.
- Publish docs puts your docs on a hosted docs portal.
- Smoke tests creates one quick test per endpoint and runs it against the app on your machine, straight from your browser.
Without an account, you sign up first and land back on the same step. Until you sign in, your document stays in your browser.

Once an action has run, your docs show its result right next to the menu. In the capture below, the API scored a C with 55 points, the mock server is running, and all six smoke tests passed against the app on this machine. Each menu entry links to its result, such as the mock URL or the test run.

Every build checked in CI
When you want this on every build instead of one click at a time, pick Keep in
sync on every build in the same menu, or Connect build… on a spec in the
Routebase app. The sheet fills in the lines for your project file and your CI
step, and it creates a build key with one click. That key only works for specs
in this one project. The package reads it only from the environment variable
ROUTEBASE_API_KEY, so it never lands in a committed file.
<PropertyGroup>
<RoutebaseProject>3f2b6c1e-0000-0000-0000-000000000000</RoutebaseProject>
</PropertyGroup>
<ItemGroup>
<RoutebaseSpecLink Include="Orders API" />
</ItemGroup>- run: dotnet build
env:
ROUTEBASE_API_KEY: ${{ secrets.ROUTEBASE_API_KEY }}
From then on, your CI build does four things on its own:
- Every merge updates Routebase. A build of your default branch pushes the document into your API in Routebase, and the tests and mock rules you linked there keep their links.
- Every pull request shows its effect. With the key set, its build lists what a push would change, breaking changes included, before you merge.
- Every push gets a grade. The API rating scores your API from 0 to 100 with a grade from A to E, and the result lands in your IDE's error list next to your compiler warnings. The rating is part of the Pro plan.
- Every breaking change waits for a decision. A change that breaks existing clients, such as a removed endpoint, stops the build, and a page in Routebase lets your team accept it, reject it or review it on a branch.
In the build log, each of these messages carries a code that starts with RB,
the same way compiler warnings start with CS, and the guide explains every one
of them.


Get started
Add the package, add the line and run your app, and your docs are there. The package supports .NET 10 and .NET 11, and it's on NuGet under the MIT license.
The guide Routebase for ASP.NET Core covers every setting and every build message. When you want the rating, the mock server and the breaking-change check on every build, connect your first build from your docs page or from Connect build… in Routebase. You can start on the Free plan, and the rating comes with the 14-day Pro trial, which needs no credit card.