AspNetCore.Docs
AspNetCore.Docs copied to clipboard
Swagger-related code missing from section "Register the database context"
Under the section titled "Register the database context" #register-the-database-context
In the listed code for Startup.cs, the code for Swagger is not included. This probably won't confuse anyone but a very new user. (I'm using .NET 5.0). The following lines are missing:
From the using statements at the top of the code:
using Microsoft.OpenApi.Models;
From ConfigureServices:
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "ToDoAPI", Version = "v1" });
});
From Configure:
Within the if(env.IsDevelopment()) if statement:
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ToDoAPI v1"));
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 583ae3e7-5915-f22b-e54c-6c100cf2a7da
- Version Independent ID: 95f2549e-29f9-e31a-b4d0-432b971643ff
- Content: Tutorial: Create a web API with ASP.NET Core
- Content Source: aspnetcore/tutorials/first-web-api.md
- Product: aspnet-core
- Technology: aspnetcore-tutorials
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
Per the doc: The preceding code:
Removes the Swagger calls.