【问题标题】:Swagger-Web Api Documentation(Bootstrapper is missing in Swashbuckle)Swagger-Web Api 文档(Swashbuckle 中缺少引导程序)
【发布时间】:2015-04-03 10:41:36
【问题描述】:

我正在尝试将 swagger 用于我的 web api 文档,为此我已经从 nuget 包安装了 Swashbuckle,但我无法在 swaggerconfig.cs 类中获取 Bootstrapper 包。那么在 swaggerconfig.cs 类中获取 Bootstrapper 包是否还有其他替代方法。请帮帮我。谢谢你。

【问题讨论】:

标签: swagger


【解决方案1】:

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

安装包 Swashbuckle

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

https://github.com/domaindrivendev/Swashbuckle

谢谢。

【讨论】:

  • 这对我帮助很大。大部分教程都使用Shwashbuckle.Core 包。
【解决方案2】:

如果Swashbuckle.Bootstrapper.Init(config); 丢失。我使用的是旧版本的 Swashbuckle 4.1.0,它对我有用。

【讨论】:

    【解决方案3】:

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

    【讨论】:

      【解决方案4】:

      在我的情况下,我通过WebApiConfig添加参考解决了这个问题

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

      【讨论】:

        【解决方案5】:

        它适用于 Swashbuckle >= 5.6.0

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-03-08
          • 1970-01-01
          • 2015-01-04
          • 1970-01-01
          • 1970-01-01
          • 2016-03-22
          • 2021-04-13
          相关资源
          最近更新 更多