ApiTestSpark 1.1.0

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

ApiTestSpark

NuGet NuGet Downloads License: MIT

Embed the API Test Spark React SPA into any .NET 10 Minimal API with a single method call. Autodiscovers your OpenAPI v3 endpoints and renders a full-featured interactive test harness at /api-test-spark/.

Live Demo  ·  GitHub  ·  NuGet


Install

dotnet add package ApiTestSpark

Quickstart

using ApiTestSpark;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();

var app = builder.Build();
app.MapOpenApi();          // /openapi/v1.json
app.MapApiTestSpark();     // /api-test-spark/

app.Run();

Navigate to https://localhost:{port}/api-test-spark/ — the harness autodiscovers all your endpoints.


Configuration

All options are optional. Pass an Action<ApiTestSparkOptions> to configure:

app.MapApiTestSpark(options =>
{
    options.OpenApiUrl             = "/openapi/v1.json";        // default: "/openapi.json"
    options.AuthScheme             = "Bearer";                  // pre-populates auth field
    options.DefaultHeaders["X-Tenant-Id"] = "acme";            // injected into every SPA request
    options.Environments           = ["Development", "Staging"]; // empty = all environments
    options.EnableDemoIntegrations = false;                     // hide JokeAPI + JSONPlaceholder
});

Options reference

Property Default Description
OpenApiUrl "/openapi.json" URL of your OpenAPI v3 JSON document. null disables autodiscovery.
AuthScheme null "Bearer", "ApiKey", or "Basic" — metadata only, never a token value.
DefaultHeaders {} Headers injected into every SPA request. Must not contain credentials — values are served publicly via the config endpoint.
Environments [] (all) Environment names where the harness is active. Empty = everywhere. Example: ["Development", "Staging"] keeps it off production.
CorsOrigins [] (same-origin) Extra origins allowed to call the config endpoint. Use when the Vite dev server and .NET API run on different ports.
EnableVerboseLogging false Emits ILogger.LogDebug for every asset served and SPA fallback. Alternatively set Logging:LogLevel:ApiTestSpark=Debug in appsettings.
EnableDemoIntegrations true When false, hides the built-in JokeAPI and JSONPlaceholder demo screens from the home page and disables their routes. Set to false to present a clean harness showing only your host API and API Doc Builder.

Features

  • OpenAPI autodiscovery — endpoints grouped by tag in a collapsible accordion; real-time search filter
  • Full metadata surface — descriptions rendered as markdown, response codes as coloured badges with expandable inline schemas, operationId as a copyable chip, schema constraint tables
  • JSON scaffold — request body pre-filled from example → default → enum[0] → type placeholder; nested objects and arrays scaffolded recursively
  • Response rendering — arrays as sortable tables, objects as editable forms, primitives in pre blocks
  • API Doc Builder (/api-docs) — select endpoints, capture live curl + responses, annotate sections, export markdown
  • Debug panel — drag-resizable, captures every request/response/error/metric; cURL snippet per request; FIFO buffered
  • Environment gating — one option keeps the harness off production
  • Demo integration toggle — set EnableDemoIntegrations = false to hide the built-in JokeAPI and JSONPlaceholder screens; show only your host API and the API Doc Builder
  • Zero extra dependencies — 181 KB package, no wwwroot changes, nothing copied to your project

Clean install — your API only

Set EnableDemoIntegrations = false to remove the JokeAPI and JSONPlaceholder demo screens entirely. The home page shows only Host API Explorer and API Doc Builder — no sample data, no external API noise.

app.MapApiTestSpark(options =>
{
    options.OpenApiUrl             = "/openapi/v1.json";
    options.Environments           = ["Development", "Staging"];
    options.EnableDemoIntegrations = false;
});

Getting the most out of API Test Spark

API Test Spark reads your OpenAPI v3 document. Every annotation you add to your API is surfaced directly in the harness. The more metadata you provide, the richer the testing experience.

Tag endpoints with "Namespace: Label" format — creates a two-level collapsible accordion:

app.MapGroup("/products").WithTags("Products: Catalog").MapProducts();
app.MapGroup("/orders").WithTags("Orders: Lifecycle").MapOrders();

Name, summarise, and describe every operation — summary is the card title; description renders as markdown:

group.MapGet("/{id}", GetById)
     .WithName("GetProductById")
     .WithSummary("Get a product by ID")
     .WithDescription("Returns a single product. Seeded IDs are **1–10**. Returns **404** if not found.");

Declare every response code — each becomes a coloured badge with an expandable inline schema:

.Produces<Product>(StatusCodes.Status200OK)
.Produces(StatusCodes.Status404NotFound)

Or use TypedResults — it infers response types automatically without extra .Produces() calls.

Annotate your schema types[Description], [Required], [Range], [MinLength], [MaxLength] all appear as columns in the schema property table:

public record Product(
    [property: Description("Display name.")][property: Required][property: MaxLength(100)]
    string Name,
    [property: Description("Unit price in USD.")][property: Range(0.01, 99999.99)]
    decimal Price
);

Set examples or defaults — the JSON scaffold fills from example → default → enum[0] → type placeholder. Without examples every field shows a generic placeholder; with them testers can fire requests immediately.

Add a workflow walkthrough to info.description — renders as markdown in the API info header; ideal for linking resource groups and describing end-to-end flows.

See the live demo and full best-practices guide for annotated source examples.


Reverse proxy

Call UseForwardedHeaders() before MapApiTestSpark() so the config endpoint reports the correct public base URL:

app.UseForwardedHeaders();
app.MapApiTestSpark();

Local development (Vite dev server)

If your React dev server and .NET API run on different ports, allow the dev origin:

app.MapApiTestSpark(options =>
{
    options.CorsOrigins = ["http://localhost:5151"];
});

Diagnostics

{
  "Logging": {
    "LogLevel": {
      "ApiTestSpark": "Debug"
    }
  }
}

License

MIT — github.com/markhazleton/apitestspark

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.
  • net10.0

    • No dependencies.

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.3.0 40 6/6/2026
1.2.0 53 6/3/2026
1.1.0 126 5/31/2026
1.0.2 93 5/30/2026
1.0.1 87 5/30/2026
1.0.0 77 5/30/2026

1.1.0 — New: EnableDemoIntegrations option hides the built-in JokeAPI and
     JSONPlaceholder demo screens for a clean production install. Type system hardened: ErrorCategory
     union expanded to include React; ErrorRecord.category and ErrorResponse.category now typed as
     ErrorCategory (was string). ErrorBoundary observability corrected. Constitution amended to v1.1.1.
     See CHANGELOG.md for full history.