SwaggerUi.OpenApi 0.6.0

dotnet add package SwaggerUi.OpenApi --version 0.6.0                
NuGet\Install-Package SwaggerUi.OpenApi -Version 0.6.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="SwaggerUi.OpenApi" Version="0.6.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SwaggerUi.OpenApi --version 0.6.0                
#r "nuget: SwaggerUi.OpenApi, 0.6.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.
// Install SwaggerUi.OpenApi as a Cake Addin
#addin nuget:?package=SwaggerUi.OpenApi&version=0.6.0

// Install SwaggerUi.OpenApi as a Cake Tool
#tool nuget:?package=SwaggerUi.OpenApi&version=0.6.0                

SwaggerUi.OpenApi

Build Status SwaggerUi.OpenApi

A package to simplify adding Swagger UI to .NET 9's Microsoft.AspNetCore.OpenApi.

Usage

In your Program.cs file Add app.AddSwaggerUi() and app.MapSwaggerUi():

builder.Services.AddOpenApi();
builder.Services.AddSwaggerUi();

var app = builder.Build();

app.MapOpenApi();
app.MapSwaggerUi();

If you want to add authentication to your Swagger you can use following helper methods:

builder.Services.AddOpenApi("v1", o =>
{
    o.AddOAuth2(authorizationUrl, tokenUrl, scopes);
});

builder.Services.AddSwaggerUi("v1", o =>
{
    o.AddOAuth2(clientId, scopes);
});

There are other helper methods for Duende Identity Server AddIdentityServer() and Auth0 AddAuth0.

You can check the samples directory for complete working examples.

Features

More snippet

Adds PowerShell and CMD cURL to the request snippet by default Request snippet

Styles

Easily change syntax highlighting style

builder.Services.AddSwaggerUi(o =>
{
    o.SyntaxHighlight = new SyntaxHighlightOptions
    {
        Theme = SyntaxHighlightThemeType.Arta
    };
});

Agate Arta Obsidian

Parameter validation

Displays the common validations in the parameters form by default

app.MapGet("/products",
    ([Range(0, 10000)] int id,
    [MinLength(3)][MaxLength(50)] string name,
    [RegularExpression("\\d\\d-\\d\\d")] string code) => id)

Validation

Authorization persistence

Persists authorization data by default and it would not be lost on browser close or refresh so you don't have to authenticate everytime.

Roadmap

✅ Basic UI

✅ Authentication

✅ Enable all the documents

✅ Implement all Swagger UI options

⏳ Improve test coverage

Acknowledgement

This project is based on Swashbuckle.AspNetCore.SwaggerUI. Thanks for their awesome work.

Pre-release builds

Get the package from here.

Build

Install the required .NET SDK and run:

$ dotnet build
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
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
0.6.0 85 11/3/2024
0.5.0 169 6/12/2024
0.4.0 71 6/9/2024
0.3.0 69 5/29/2024
0.2.0 63 5/25/2024
0.1.0 70 5/15/2024