I built my first API and am trying to publish to Azure.
I get the following error "Be sure that the Startup.cs for your application is calling AddSwaggerGen from within ConfigureServices in order to generate swagger file. Visit https://go.microsoft.com/fwlink/?LinkId=2131205&CLCID=0x409 for more information."
Failed to generate swagger file. Error dotnet swagger tofile
Here is my code from Startup.cs:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "PeopleSearch v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
Does anyone know what I am doing wrong?
I have been seeing so many questions regarding this issue but not even a single reliable answer. I tried almost all of the solutions with little to no success, the only thing which resolved it for me was the following
bin
, obj
, and .config
folders (.config
is a folder, not a file)I am not sure if this is going to resolve the issue for anyone else but it did work for me so worth a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With