0

I've written some endpoints in webApi C#. On my dev machine, when I run my code and open swagger all endpoint are available as expected. When I deploy my code to another server when I run swagger I only see a couple of my post methods. I'm missing some post methods and all my get methods.

From the deployed server in swagger I receive an error: -

{"schemaValidationMessages":[{"level":"error","message":"Can't read from file http://192.168.19.3/WooService/swagger/docs/v1"}]}

I have tried re-deploying several times, removing the service from IIS and recreating, but none of these seem to work. Can someone tell me where I'm likely to find this file on my local service and where I should place it on the server I'm deploying too, or if anyone knows another way to resolve this issue.

My Swagger config is very basic

using System.Web.Http;
using WebActivatorEx;
using WooService;
using Swashbuckle.Application;

[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]

namespace WooService
{
    public class SwaggerConfig
    {
        public static void Register()
        {
            var thisAssembly = typeof(SwaggerConfig).Assembly;

            GlobalConfiguration.Configuration
                .EnableSwagger(c =>
                    {
                        c.SingleApiVersion("v1", "WooService");
                    })
                .EnableSwaggerUi();
        }
    }
}

As mentioned nothing has really changed other than a couple of endpoints. The config must be ok because it runs fine locally. Its on the deployed machine it's suddenly not showing all end points

bilpor
  • 3,467
  • 6
  • 32
  • 77
  • 1
    What happens if you open the url in your browser? Can you access the file? – mamen Oct 15 '21 at 06:49
  • Post your startup.cs – Vivek Nuna Oct 15 '21 at 07:02
  • It looks like you have given wrong path for swagger.json in SwaggerEndpoint method – Vivek Nuna Oct 15 '21 at 07:09
  • If I open the url, I see 4 of my post methods and nothing else. I've deployed several times. Originally, all my methods where showing. It seems that the v1 file is corrupt, but I dont know where it is. My startup.cs shoulld be fine as nothing has changed there, and as I said it works fine on my dev box it's only failing after deploy – bilpor Oct 15 '21 at 07:09
  • If you use automated deployments through a CI, check, if the right branch is deployed. Maybe you deploy an older version of your app with lesser endpoints defined. – mamen Oct 15 '21 at 08:17
  • Can you give more details? .net version? Swashbuckle version, etc, etc. – JHBonarius Oct 18 '21 at 09:37
  • Does this answer your question? [Can't read from file issue in Swagger UI](https://stackoverflow.com/questions/32188386/cant-read-from-file-issue-in-swagger-ui) – JHBonarius Oct 18 '21 at 09:38

0 Answers0