5

Package version 6.0.0-beta902

Examples :

public class TestModel
{
    /// <summary>
    /// This is description of Name
    /// </summary>
    public string Name { get; set; }
}

public IActionResult HelloWorld(TestModel model)
{
    return Content("hello " + model.Name);
}

Why Swagger UI does not show Name parameter description ?

Atloka
  • 185
  • 3
  • 12

1 Answers1

4

This is commonly caused by a missing configuration, make sure you have the IncludeXmlComments with the correct path to your XML document.

Here is a way to include all XML documents on the configuration:

    public void ConfigureServices(IServiceCollection services)
    {
        // Add Swashbuckle
        services.AddSwaggerGen(options =>
        {
            options.DescribeAllEnumsAsStrings();
            options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info()
            {
                Title = "My API",
                Version = "v1",
                Description = "My API",
                TermsOfService = "Terms Of Service"
            });

            //Set the comments path for the swagger json and ui.
            var basePath = PlatformServices.Default.Application.ApplicationBasePath;
            foreach (var name in Directory.GetFiles(basePath, "*.XML", SearchOption.AllDirectories))
            {
                options.IncludeXmlComments(name);
            }
        });
        // Add framework services.
        services.AddMvc();
    }



Here is an example showing correctly:

http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter=TestEnum#/TestEnum/TestEnum_Put

And the code behind that is on GitHub:

https://github.com/heldersepu/SwashbuckleTest/blob/master/Swagger_Test/Models/ViewModelTest.cs

Helder Sepulveda
  • 15,500
  • 4
  • 29
  • 56