Developer tool UI for ASP.NET Core
$ dotnet add package LonG.DevToolASP.NET Core host and static UI for the API Explorer dev tool. The package includes the built React SPA under wwwroot/dev-tool-ui and middleware to serve it (optionally under a path like /_devtool) and to cache your API’s OpenAPI/Swagger document.
Serves the API Explorer SPA – Single-page app that loads your API’s OpenAPI (Swagger) JSON and lets you:
categoryId)Optional integration – Use MapDevToolUi(path) to mount the UI at a path (e.g. /_devtool) in an existing app. The middleware can fetch your OpenAPI document from the same host and cache it (e.g. in the host’s wwwroot) so the SPA can load it.
DevTool.UI.dll with middleware and options (e.g. MapDevToolUi, SwaggerJsonOptions, SPA fallback).wwwroot/dev-tool-ui (HTML, JS, CSS). Include these in your app’s serving path (e.g. next to the app or in your own wwwroot) so the middleware or static files middleware can serve them.From the solution directory:
wwwroot/dev-tool-ui):
dotnet build DevTool.UI/DevTool.UI.csproj
dotnet pack DevTool.UI/DevTool.UI.csproj -c Release -o ./nupkgs
The resulting .nupkg includes the DLL and wwwroot/dev-tool-ui with the built SPA.
After building and packing (see above), push the .nupkg from ./nupkgs to a NuGet feed. Options:
YOUR_API_KEY with your key):
dotnet nuget push ./nupkgs/NETDevTool.*.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json
https://www.nuget.org/packages/NETDevTool after validation.write:packages (and read:packages if you need to restore from GitHub).USERNAME and YOUR_GITHUB_TOKEN:
dotnet nuget add source "https://nuget.pkg.github.com/USERNAME/index.json" --name github --username USERNAME --password YOUR_GITHUB_TOKEN --store-password-in-clear-text
Or store the token in a credential manager; see GitHub: Publishing to GitHub Packages.dotnet nuget push ./nupkgs/NETDevTool.*.nupkg --source "https://nuget.pkg.github.com/USERNAME/index.json" --api-key YOUR_GITHUB_TOKEN
dotnet restore / Visual Studio.https://pkgs.dev.azure.com/ORG/_packaging/FEED/nuget/v3/index.json).az artifacts universal download / credential provider, orFEED_URL and PAT):
dotnet nuget add source "FEED_URL" --name azure --username any --password PAT --store-password-in-clear-text
dotnet nuget push ./nupkgs/NETDevTool.*.nupkg --source azure
dotnet nuget push to the feed’s source URL.Push to NuGet.org on release:
- name: Pack
run: dotnet pack DevTool.UI/DevTool.UI.csproj -c Release -o nupkgs
- name: Push to NuGet.org
run: dotnet nuget push nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
Store NUGET_API_KEY in the repo’s Secrets. For GitHub Packages or Azure Artifacts, use the corresponding source URL and secret (e.g. GITHUB_TOKEN or an Azure PAT).
Run the DevTool.UI project and open the app in the browser. It serves the SPA from the project’s wwwroot. Point the in-app “OpenAPI URL” to your API’s OpenAPI/Swagger URL (e.g. https://localhost:5235/openapi/v1.json).
When you reference the package and want to host the Explorer under a path (e.g. /_devtool):
wwwroot/dev-tool-ui from the package is available to your app (e.g. copy from the package’s wwwroot into your project’s wwwroot, or use a file provider that points at the package content).MapDevToolUi(path) (or the overload with SwaggerJsonOptions) in your pipeline after UseRouting (or in the appropriate Map branch). The middleware serves the SPA and can fetch/cache your OpenAPI document from the same host.See the project’s middleware (e.g. SpaFallbackExtensions, SwaggerJsonOptions) for configuration (OpenAPI path, cache location, base path).
wwwroot/dev-tool-ui.See the repository license.