In ASP.NET Core-6 Web API, I am implementing Swagger Documentation.
I have this code.
SwaggerDocOptions:
public class SwaggerDocOptions
{
    public string Title { get; set; }
    public string Description { get; set; }
    public string Organization { get; set; }
    public string Email { get; set; }
}
Program.cs
builder.Services.AddSwaggerGen();
builder.Services.AddOptions<SwaggerGenOptions>()
    .Configure<IApiVersionDescriptionProvider>((swagger, service) =>
    {
        foreach (ApiVersionDescription description in service.ApiVersionDescriptions)
        {
            swagger.SwaggerDoc(description.GroupName, new OpenApiInfo
            {
                Title = swaggerDocOptions.Title,
                Version = description.ApiVersion.ToString(),
                Description = swaggerDocOptions.Description,
                TermsOfService = new Uri("mysite.org/LICENSE.md"),
                Contact = new OpenApiContact
                {
                    Name = swaggerDocOptions.Organization,
                    Email = swaggerDocOptions.Email
                },
                License = new OpenApiLicense
                {
                    Name = "MIT",
                    Url = new Uri("mysite.org/MyApp")
                }
            });
        }
        var security = new Dictionary<string, IEnumerable<string>>
        {
            {"Bearer", new string[0]}
        };
        swagger.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
        {
            Description = "JWT Authorization header using the Bearer scheme.",
            Name = "Authorization",
            In = ParameterLocation.Header,
            Type = SecuritySchemeType.ApiKey,
            Scheme = "Bearer",
            BearerFormat = "JWT"
        });
        swagger.OperationFilter<AuthorizeCheckOperationFilter>();
        var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
        var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
        swagger.IncludeXmlComments(xmlPath);
    });
// Register and Configure API versioning
builder.Services.AddApiVersioning(options =>
{
    options.AssumeDefaultVersionWhenUnspecified = true;
    options.DefaultApiVersion = new ApiVersion(1, 0);
    options.ReportApiVersions = true;
});
// Register and configure API versioning explorer
builder.Services.AddVersionedApiExplorer(options =>
{
    options.GroupNameFormat = "'v'VVV";
    options.SubstituteApiVersionInUrl = true;
});
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseSwaggerUI();
I want the fields that are required to be specified in the Swagger Documentation. That is,
https://localhost:44361/swagger.index.html
However, when I lauched the Application, the required fields are not specified in
https://localhost:44361/swagger.index.html.
How do I achieve this?
Thanks
 
    