RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.61k stars 1.22k forks source link

I can't load Swagger UI plugins through my NSwag configuration. #4921

Open jarleli opened 1 week ago

jarleli commented 1 week ago

I wanted my NSwag swagger to use a plugin for hierarchical tags to properly visualize several levels in the API structure and domain and found the perfect Swagger Plugin for the job, but I can't add plugins to swagger without manipulating the swagger HTML.

Shoutout to the plugin here: https://www.npmjs.com/package/swagger-ui-plugin-hierarchical-tags

I can provide a PR to allow you to set plugins through:

app.UseSwaggerUi(setting =>
{
    setting.AdditionalPlugins.Add("PluginName", "path/toPluginScript.js");
}); 

It wasn't possible to do this through additionalSettings because the script has to load before the plugins:[].

I feel having general support for swagger plugins through NSwag must be of general interest and figured I'd hear if that's true.

jarleli commented 1 week ago

I tested this in my own project, but is there any additional tests or qa I can provide to increase the chances of this being merged?