AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Swagger-related code missing from section "Register the database context"

Open Loves2Code opened this issue 5 years ago • 1 comments

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.

Loves2Code avatar Feb 15 '21 08:02 Loves2Code

Per the doc: The preceding code:

Removes the Swagger calls.

Rick-Anderson avatar Feb 15 '21 22:02 Rick-Anderson