1
votes

I have a problem with the Swagger UI (or the swagger.json file specifically) not being updated when I deploy my code to the server. If I go to the Swagger UI page, the server gives me an old version of the docs.

Everything works locally, so the problem must be related to the deployment process or IIS.

Any ideas on what might cause this, and how I can fix it?

I have tried the following:

  • Deleted the XML-comments file generated by Web API and regenerated it
  • Restarted the IIS site on the server
  • Deleted all files in the site and redeployed
  • Numerous redeployments

(using Swashbuckle for .NET Framework, not .NET Core)

2
Try changing the Swagger json file name, and do a rebuild and test if the value are updated, this will give you a better view of what might be going wrong. - Utkarsh Bais
where can I do that? Seems like the file is generated at runtime, and can't find it anywhere in SwaggerConfig.cs - msk
In Visual Studio, go to Project Properties and in the Build tab, under output heading you will have the XML documentation file, that should be your file. For case of JSON I think this will help you out github.com/aspnet/Docs/blob/master/aspnetcore/tutorials/… - Utkarsh Bais
That is very strange... (Swashbuckle for .NET Framework, not .NET Core) does not have a swagger.json file, here is mine: swashbuckletest.azurewebsites.net/swagger/ui/index - Helder Sepulveda

2 Answers

0
votes

You may need to clear your browser's cache. I just encountered this problem and solved by clear my browser's cache

0
votes

In my case, the set attribute was as private, after that updated the swagger without a problem.

Before: public string Street { get; private set; }

After: public string Street { get; set; }

Hope this helps = )