Can't read from file issue in Swagger UI

后端 未结 6 1582
无人共我
无人共我 2021-01-31 13:07

I have incorporated swagger UI in my application.

When I try and see the swagger UI, I get the documentation of the API nicely but after some time it shows some error i

6条回答
  •  遥遥无期
    2021-01-31 14:05

    To anynoe having similar issue when using Swashbuckle.OData:

    I was having issues to integrated Swagger with our OData endpoints (using ODataController for API and Swashbuckle.OData NuGet package). I had to write our own document filter for it and add it:

    GlobalConfiguration.Configuration
                .EnableSwagger(c =>
                    {
                        c.SingleApiVersion("v1", "OurSolution.API");
                        c.DocumentFilter();
                        //c.CustomProvider((defaultProvider) => new ODataSwaggerProvider(defaultProvider, c, GlobalConfiguration.Configuration));
                        c.IncludeXmlComments(GetXmlCommentsPath());
                        c.UseFullTypeNameInSchemaIds();
                        c.RootUrl(req => ConfigurationManager.AppSettings["AppUrl"]);
                    })
                .EnableSwaggerUi(c =>
                {
                    c.DisableValidator();
                });
    

    Apparently in order to avoid validation error I had to comment out line which is setting ODataSwaggerProvider along with turning off validator as mentioned in posts above. This makes usefulness of Swashbuckle.OData questionable yet I didn't test whatever it works with vanilla Swashbuckle.

    Note: I used approach described on GitHub page for Swashbuckle.OData but it was not working: showing no possible endpoints at all. Maybe somebody knows better solution.

提交回复
热议问题