Home > OS >  Swashbuckle does not display the API correctly
Swashbuckle does not display the API correctly

Time:12-16

Swashbuckle was used in my project, I followed the documentation, but at the end an error was displayed. enter image description here

services.AddSwaggerGen(c =>
  {
    c.SwaggerDoc("v1", new OpenApiInfo
    {
        Version = "v1",
        Title = "ToDo API",
        Description = "A simple example ASP.NET Core Web API",
        TermsOfService = new Uri("https://example.com/terms"),
        Contact = new OpenApiContact
        {
            Name = "Shayne Boyer",
            Email = string.Empty,
            Url = new Uri("https://twitter.com/spboyer"),
        },
        License = new OpenApiLicense
        {
            Name = "Use under LICX",
            Url = new Uri("https://example.com/license"),
        }
    });
      });

    app.UseSwagger(c =>
    {
        c.SerializeAsV2 = true;
    });

app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
    });

What did i do wrong? Thanks for the help!

CodePudding user response:

I have encountered this problem before, and I can reproduce your problem, but I am not sure if this is your problem.

enter image description here

All configurations follow the official documentation:

enter image description here

If the above method cannot be solved, can you post your specific error message?

  • Related