Swagger无法在以OWIN运行的Azure Web应用程序上运行 [英] Swagger not working on Azure Web app running as OWIN

查看:124
本文介绍了Swagger无法在以OWIN运行的Azure Web应用程序上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实现为OWIN中间件的ASP.NET Web API.我将其托管在azure上,现在我在使用招摇工具时遇到了问题.它可以在localhost上正常运行,但是当我在azure上尝试时,我得到了:

I have a ASP.NET Web API implemented as OWIN middleware. I hosted it on azure and now I have a problem using swagger. It is perfectly working on localhost but when I try it on azure I get this:

我在API上对swagger进行配置的方式是完全删除SwaggerConfig.cs文件,并将所有配置添加到我的Startup.cs类中,如下所示:

The way I did my configuration for swagger on the API was to completely remove SwaggerConfig.cs file and add all the configuration into my Startup.cs class as shown here: How to generate documentation using swashbuckle for WebApi 2 with Owin . If it is going to help, I am trying to implement oAuth2 between my API, identity server and client application.

您能帮我找出未在Azure上获得敏捷功能的原因吗?

Can you help me find out what is the reason for not getting swagger functionality on Azure?

我也从此处尝试了该解决方案,但没有成功.我去了API-> Properties-> Buld选项卡->更改为"Release"配置->在输出路径中添加了"Debug"配置中的内容,却没有任何内容.

I also tried the solution from here but without success. I went to my API->Properties->Buld tab->Changed to 'Release' configuration->In the output path added the same what was in the 'Debug' configuration and nothing.

我在Azure上的bin文件夹:

My bin folder on Azure:

推荐答案

这是延迟答复,但将来可能会对某人有所帮助. 我这样解决了这个问题:

This is late reply but may help someone in future. I solved this issue this way:

  1. 在项目设置中将XML文档文件路径设置为:wwwroot \ api.xml
  2. 让Swagger知道文件在ConfigureConfigs方法中的位置 Startup.cs:

  1. Set XML documentation file path in project settings to : wwwroot\api.xml
  2. Let Swagger know where the file is within ConfigureServices method in Startup.cs:

        services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });

        // Set the comments path for the Swagger JSON and UI.
        var xmlFile = "api.xml";
        var xmlPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", xmlFile);
        c.IncludeXmlComments(xmlPath);
    });

您可以设置不同的路径,但是从此示例中您将了解如何执行此操作.

You can set different paths but you will get the idea of how to do it from this example.

这篇关于Swagger无法在以OWIN运行的Azure Web应用程序上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆