Routebase.AspNetCore
1.0.1
Prefix Reserved
dotnet add package Routebase.AspNetCore --version 1.0.1
NuGet\Install-Package Routebase.AspNetCore -Version 1.0.1
<PackageReference Include="Routebase.AspNetCore" Version="1.0.1" />
<PackageVersion Include="Routebase.AspNetCore" Version="1.0.1" />
<PackageReference Include="Routebase.AspNetCore" />
paket add Routebase.AspNetCore --version 1.0.1
#r "nuget: Routebase.AspNetCore, 1.0.1"
#:package Routebase.AspNetCore@1.0.1
#addin nuget:?package=Routebase.AspNetCore&version=1.0.1
#tool nuget:?package=Routebase.AspNetCore&version=1.0.1
Routebase.AspNetCore
Stop the OpenAPI document of your ASP.NET Core API from drifting away from the code. Every build writes it as JSON and YAML, and your app serves a beautiful interactive API reference for it. Connected to Routebase, the same build lints and rates the API, sets up a mock server and smoke tests, and fails when a change breaks the contract. It works with Microsoft.AspNetCore.OpenApi, Swashbuckle and NSwag.
Getting started
Add the package to your app:
dotnet add package Routebase.AspNetCore
After dotnet build, the document sits in obj/, for example as obj/MyApi.json and
obj/MyApi.yaml. The package brings Microsoft.Extensions.ApiDescription.Server, the build-time
generation from Microsoft, which consists of build files. So it adds no runtime dependency to your
app.
To write the document, the build starts your app without its runtime configuration. Writing the document on build shows how to skip a registration that needs a secret.
API reference
Map the reference page in Program.cs:
using Routebase.AspNetCore;
app.MapRoutebaseApiReference();
The page is served at /routebase in a light and a dark theme. It shows the document written at
build time, so it needs no runtime document route, and its request playground calls your API from
the browser. On localhost, the page also shows the menu Open in Routebase, which takes your
document to Routebase for a rating, a mock server, published docs or smoke tests.
While your app runs in Development, the page also lets the Routebase app call your API from the
browser. It answers CORS for that one origin and never allows credentials. So a test run you start
in the Routebase web app reaches your app on localhost. Set options.Cors = RoutebaseCors.Never
to leave CORS to your app alone.
Connecting a build to Routebase
Link the document to a spec of your Routebase project in the project file:
<PropertyGroup>
<RoutebaseProject>3f2b6c1e-0000-0000-0000-000000000000</RoutebaseProject>
</PropertyGroup>
<ItemGroup>
<RoutebaseSpecLink Include="Orders API" />
</ItemGroup>
The API key comes only from the environment variable ROUTEBASE_API_KEY, so it cannot be committed
by accident. Every CI build of the default branch then pushes the document into the draft of the
spec, and the build reports what Routebase found:
- The API rating and the style-guide report show in the build log and in the error list of your IDE. The rating is part of the Routebase Pro plan.
- The first push into an empty spec sets up a mock server with rules and smoke tests, as far as the key's permissions allow.
- A breaking change against the draft fails the build, and the error links to the page in Routebase where you decide.
A pull request build pushes nothing. With the key set, it previews what the push would change.
Requirements
- .NET 10 or .NET 11
- An app that describes its endpoints with Microsoft.AspNetCore.OpenApi, Swashbuckle or NSwag
- For a connected build, an API key with
specs:read,specs:writeandspecs:delete
Writing the document and serving the reference need no Routebase account.
Documentation
The guide Routebase for ASP.NET Core covers everything else, from describing responses and the options of the reference page to every setting and every build message.
Feedback
Send questions and feedback to support@routebase.dev.
License
Routebase.AspNetCore is licensed under the MIT license, see LICENSE.txt in the package. The
licenses of its third-party components are in THIRD-PARTY-NOTICES.txt, which the reference page
also serves at /routebase/THIRD-PARTY-NOTICES.txt.
| Product | Versions 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. net11.0 is compatible. |
-
net10.0
- Microsoft.Extensions.ApiDescription.Server (>= 10.0.0)
-
net11.0
- Microsoft.Extensions.ApiDescription.Server (>= 11.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.