Я разработал плагин API для NopCommerce 4.5. Можно ли добавить документацию Swagger для этого API? Как это сделать?





В плагине нужно добавить новый файл NopStatup.cs и настроить промежуточное ПО Swagger.
Пример:
public partial class PluginNopStartup : INopStartup
{
/// <summary>
/// Add and configure any of the middleware
/// </summary>
/// <param name = "services">Collection of service descriptors</param>
/// <param name = "configuration">Configuration of the application</param>
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "ToDo API",
Description = "An ASP.NET Core Web API for managing ToDo items",
TermsOfService = new Uri("https://example.com/terms"),
Contact = new OpenApiContact
{
Name = "Example Contact",
Url = new Uri("https://example.com/contact")
},
License = new OpenApiLicense
{
Name = "Example License",
Url = new Uri("https://example.com/license")
}
});
});
}
/// <summary>
/// Configure the using of added middleware
/// </summary>
/// <param name = "app">Builder for configuring an application's request pipeline</param>
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI();
}
/// <summary>
/// Gets order of this startup configuration implementation
/// </summary>
public int Order => 1;
}