SwAger与WebApi和OWIn

时间:2016-11-18 07:21:04

标签: asp.net-web-api owin swagger swashbuckle

我想使用Swagger根据.Net WebApi和Owin for OAuth来记录我的api。 我使用Swashbuckle.Core Nuget Package并在我的启动类中配置swagger:

public void Configuration(IAppBuilder app)
    {

        HttpConfiguration config = new HttpConfiguration();
        IContainer container = AutoFacConfig.Register(config, app);
        app.UseCors(CorsOptions.AllowAll);


        ConfigureOAuth(app, container);

        WebApiConfig.Register(config);
        AutoMapperConfig.Register();

        config
           .EnableSwagger(c =>
          {
              c.SingleApiVersion("v1", "My API");
              c.IncludeXmlComments(GetXmlCommentsPath());
          })
           .EnableSwaggerUi();

        app.UseWebApi(config);
    }

这是我的GetXmlCommentsPath方法

protected static string GetXmlCommentsPath()
    {
        return System.String.Format(@"{0}\bin\My.WebApplication.XML", System.AppDomain.CurrentDomain.BaseDirectory);
    }

如果现在我启动我的应用程序,我会收到StackOverFlowException并且Swagger网站告诉我

Can't read from server. It may not have the appropriate access-control-origin settings.

我做错了什么?

0 个答案:

没有答案