Swagger is not generating swagger.json
I was stuck on this problem for hours... and I found the reason...
Check the code below !!
..Startup.cs..
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseMvc();
app.UseSwagger(); // if I remove this line, do not work !
app.UseSwaggerUi3();
}
Just wanted to add my experience here as well.
I have given the version in configureServices
as V1
(notice the V
in caps) and
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", //this v was in caps earlier
new Swashbuckle.AspNetCore.Swagger.Info
{
Version = "v1",//this v was in caps earlier
Title = "Tiny Blog API",
Description = "A simple and easy blog which anyone love to blog."
});
});
//Other statements
}
And then in the configure
method it was in small case
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Tiny Blog V1");
});
}
May be it can help someone.