in my asp.net core 2.1 api I have added static files serving and Swashbuckle, but apparently can't find the generated .json
services.AddSwaggerGen(x =>
x.SwaggerDoc("Swagger", new Info { Title = "Asp.Net Core 2 Api", Description = "Swagger Core Api" }));
----
app.UseCors("AllowAll");
app.UseAuthentication();
app.UseStaticFiles();
app.UseSwagger();
app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/swagger.json", "Core Api"));
any idea? thanks
Your swagger end-point has the wrong Url, hence the 'Not Found' Error.
Swagger documents constructed via the default way have their url in the format /swagger/<document-name>/swagger.json
where is the name (first string) parameter supplied in the call to x.SwaggerDoc("Swagger", new Info {...});
In your case you supplied "Swagger", hence your endpoint url should be "/swagger/Swagger/swagger.json"
.
and in your ConfigureServices your call should be like
app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/Swagger/swagger.json", "Core Api"));