WebApiDocumentator 1.1.9

dotnet add package WebApiDocumentator --version 1.1.9
                    
NuGet\Install-Package WebApiDocumentator -Version 1.1.9
                    
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="WebApiDocumentator" Version="1.1.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WebApiDocumentator" Version="1.1.9" />
                    
Directory.Packages.props
<PackageReference Include="WebApiDocumentator" />
                    
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 WebApiDocumentator --version 1.1.9
                    
#r "nuget: WebApiDocumentator, 1.1.9"
                    
#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 WebApiDocumentator@1.1.9
                    
#: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=WebApiDocumentator&version=1.1.9
                    
Install as a Cake Addin
#tool nuget:?package=WebApiDocumentator&version=1.1.9
                    
Install as a Cake Tool

Nuget Nuget

WebApiDocumentator

WebApiDocumentator is a quick and easy way to create an interface to document a WebAPI built in .NET Core. It creates a user-friendly interface and has options for endpoint testing.

Features

  • Automatic documentation using XML metadata from C# code
  • Show endpoints tree estructure
  • HTML interface
  • Test endpoints

Installation

  1. Install the nuget package via the package manager:

    dotnet add package WebApiDocumentator
    
  2. Or by using the NuGet CLI:

    nuget install WebApiDocumentator
    

Quick Start

Step 1: Add WebApiDocumentator to Your API

In your Program.cs, you will need to add the middleware to your service collection and configure the options.

1.1 Configure Options

You can customize the url for the page and add basic data via DocumentatorOptions.

In appsettings json using IOptions<DocumentatorOptions> file like:

  "DocumentatorOptions": {
    "ApiName": "Your api name",
    "Version": "Your version, it's a string",
    "Description": "Full descripcion about your API",
    "DocsBaseUrl": "documentation path, defatul it's [api root]/WebApiDocumentator",
    "EnableTesting": true,
    "ShopOpenApiLink": false
  }

Then in the definition of the API:

builder.Services.AddWebApiDocumentator(
    options => builder.Configuration.GetSection(SmartCacheOptions.SectionKey).Bind(options)
    );

Or directly like:

public void ConfigureServices(IServiceCollection services)
{
    services.AddWebApiDocumentator(options =>
    {
        options.ApiName = "Test Api";
        options.Version = "v1";
        options.Description = "The best API in the world!";
        options.DocsBaseUrl = "docs/api";
        options.EnableTesting = true;
        options.ShopOpenApiLink = false;
    });
}

//minimal api with default options
builder.Services.AddWebApiDocumentator();
1.2 Add the user interface

In your Configure method, add the middleware to the pipeline using UseWebApiDocumentator():

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    // Add other middlewares like authentication, etc.    
    app.UseWebApiDocumentatorSessions();    // Optional if you already use app.UseSession()
    app.UseRouting();
    app.MapRazorPages();                    // If you are using razor pages should be before UseWebApiDocumentator()
    app.MapWebApiDocumentator();            // Required for WebApiDocumentator routes
}

//minimal apivar 
app = builder.Build();
...
app.UseWebApiDocumentatorSessions();    // Optional if you already use app.UseSession()
app.UseRouting();
app.MapRazorPages();                    // If you are using razor pages should be before UseWebApiDocumentator()
app.MapWebApiDocumentator();            // Required for WebApiDocumentator routes
...

app.Run();

Step 2: Interface HTML

To access to the interface you can use the default url

[your api url]/WebApiDocumentator

Or if you personalize the url then use your own url

[your api url]/api/docs

Remind: Always you can use a defatult WebApiDocumentator page.

2.1 Home page
  • Show the name, version and description from your options.
  • Show the schema of your API
  • Right side bar with to search and select endpoint
2.2 Selected endpoint
  • Show documentation information
  • Show params type and from where
  • Show testing tab

Models

If you use Options Pathern then this is the class should me match in the json configuration file. And this is the default values.

public class DocumentatorOptions
{
    public static string SectionKey = nameof(DocumentatorOptions);
    public string ApiName { get; set; }
    public string Version { get; set; }
    public string Description { get; set; }
    public string DocsBaseUrl { get; set; } = "/api/docs";
    public bool EnableTesting { get; set; } = true;
    public bool ShopOpenApiLink { get; set; }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.

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.1.9 130 8/11/2025
1.0.8 146 8/4/2025
1.0.7 170 6/27/2025
1.0.6 145 6/15/2025
1.0.5 153 6/4/2025
1.0.4 104 6/1/2025
1.0.3 148 5/29/2025
1.0.2 145 5/28/2025
1.0.1 147 5/27/2025
1.0.0 157 5/26/2025

Separate UseWebApidocumentator() into UseWebApiDocumentatorSessions and MapWebApiDocumentator to follow more correct middleware steps and clarifly what we are doing. Fixed: services.AddEndpointsApiExplorer(); because have a dependency about AddEndpointsApiExplorerIApiDescriptionGroupCollectionProvider in the services. Removed suport NET6 and NET7 because end of support by Microsoft. Update dependencies.