swaggergen add service not getting info in .net core

C#
services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new OpenApiInfo { Title = "The API", Version = "v1" });
});using Microsoft.OpenApi.Models;
Source

Also in C#: