This is how I made
https://nuget.org/packages/OpenAPISwaggerUI in order to see the UI for an ASP.NET 9 project.
And hey,if you have any feedback,don’t be shy! Drop by https://github.com/ignatandrei/openAPISwaggerUI/ and let me know.
Now I want the users of my ASP.NET 9 project to have a buffet of Swagger UIs (Swashbuckle,Redoc,Scalar,NSwag,VisualAutomation) and let them pick their favorite flavor.
The master plan? Create an endpoint (let’s call it /swagger) that showcases all these UIs like a proud parent at a talent show.
But wait,there’s more! I want to sprinkle in some custom info – project version,UI links,and other goodies.
Enter the RazorBlade NuGet package,my trusty sidekick for crafting a Razor page.
So I used the RazorBlade nuget package to create a Razor page .
<ItemGroup> <PackageReference Include="RazorBlade" Version="0.7.0" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" /> </ItemGroup>
And voilà,the SwaggerData.cshtml Razor page is born:
@using OpenAPISwaggerUI
@inherits RazorBlade.PlainTextTemplate<SwaggerUIData>
<html>
<body>
<h1>Swagger UI</h1>
<h2>
<a href="@Model.SwaggerEndpoint" target="_blank">SwaggerEndpoint</a>
</h2>
<ul>
<li>
<a href="@Model.Swashbuckle" target="_blank">Swashbuckle</a>
</li>
<li>
<a href="@Model.NSwag" target="_blank">NSwag</a>
</li>
<li>
<a href="@Model.ReDoc" target="_blank">Redoc</a>
</li>
<li>
<a href="@Model.Scalar" target="_blank">Scalar</a>
</li>
<li>
<a href="@Model.Blockly" target="_blank">VisualAutomation</a>
</li>
</ul>
<small>
Generated by <a href="https://www.nuget.org/packages/OpenAPISwaggerUI" target="_blank"> @Model.AssemblyName : @Model.MyName</a>
</small>
</body>
</html>
Leave a Reply