Automates Kiota SDK generation and integrates it with Scalar API documentation for ASP.NET Core minimal APIs with native AOT support.
dotnet add package Scalar.Kiota.Extension --prerelease
using Scalar.Kiota.Extension;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScalarWithKiota();
var app = builder.Build();
app.MapScalarWithKiota("/api");
await app.RunAsync();
builder.Services.AddScalarWithKiota(options =>
{
options.WithTitle("My API") // Default: "{ApplicationName} API"
.WithTheme(ScalarTheme.Saturn) // Default: Saturn
.WithSdkName("MyApiClient") // Default: "ApiClient" (space-free for compatibility)
.WithLanguages("TypeScript", "CSharp") // Default: ["TypeScript"]
.WithOutputPath("./custom-output") // Default: "wwwroot/.scalar-kiota"
.WithOpenDocsOnStartup(); // Default: false
options.BundleTypeScript = true; // Default: true
options.DocumentationPath = "/docs"; // Default: null (uses pattern)
});
TypeScript
- Bundled with esbuild for browser usageCSharp
- .NET clientPython
- Python clientJava
- Java clientGo
- Go clientPHP
- PHP clientRuby
- Ruby clientSwift
- Swift clientCLI
- Command line client
ScalarTheme.Default
, ScalarTheme.Alternate
, ScalarTheme.Moon
, ScalarTheme.Purple
, ScalarTheme.Solarized
,
ScalarTheme.BluePlanet
, ScalarTheme.Saturn
, ScalarTheme.Kepler
, ScalarTheme.Mars
, ScalarTheme.DeepSpace
- Downloads OpenAPI spec from
/openapi/v1.json
- Generates SDKs using Kiota CLI (auto-installed if missing)
- For TypeScript: creates package.json, installs dependencies, bundles with esbuild
- Creates config.js that exposes the SDK to Scalar's "Try It" feature
- Only regenerates when OpenAPI spec changes (SHA256 hash-based caching)
wwwroot/.scalar-kiota/
├── openapi.json # Downloaded spec
├── config.js # Scalar integration
├── sdk.js # Bundled TypeScript (if enabled)
├── .spec.hash # Cache validation
└── [language]/ # Generated SDK sources
- Download .NET 10.0 Preview
- Install Node.js (for TypeScript bundling)
This project is licensed under the MIT License.