Swagger-Web Api 文档(Swashbuckle 中缺少 Bootstrapper)

Swagger-Web Api Documentation(Bootstrapper is missing in Swashbuckle)

我正在尝试为我的网络 api 文档使用 swagger,为此我已经从 nuget 包中安装了 Swashbuckle,但我无法在 swaggerconfig.cs class.那么在 swaggerconfig.cs class 中是否还有其他方法可以获取 Bootstrapper 包。请帮帮我。谢谢你。

如果您的服务托管在 IIS 中,您只需安装以下 Nuget 包即可开始公开 Swagger 文档和相应的 swagger-ui:

安装包 Swashbuckle

这将添加对 Swashbuckle.Core 的引用并自动安装引导程序

https://github.com/domaindrivendev/Swashbuckle

谢谢。

我已经发布了教程和代码here如果你想看

如果缺少 Swashbuckle.Bootstrapper.Init(config);。我使用了旧版本的 Swashbuckle 4.1.0,它对我有用。

在我的例子中,我通过 WebApiConfig

添加参考来解决它
public static class WebApiConfig
{

    public static void Register(HttpConfiguration config)
    {
        config.MapHttpAttributeRoutes();
        config.EnableSwagger(c =>
        {
            c.SingleApiVersion("v1", "WebAPI");
        }).EnableSwaggerUi();
    }
}

适用于 Swashbuckle >= 5.6.0

//namespace
using Swashbuckle.Application;

var config = new HttpConfiguration();
config.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API")).EnableSwaggerUi();