domaindrivendev / Swashbuckle.WebApi

Seamlessly adds a swagger to WebApi projects!
BSD 3-Clause "New" or "Revised" License
3.07k stars 677 forks source link

How to Achieve SwaggerUI Resources List With Description #1034

Open stantoxt opened 7 years ago

stantoxt commented 7 years ago

In the demo here swagger demo url,the resource list h2 has some description, examplepicture

How can I achieve this effects?

venerik commented 7 years ago

I don't think there is any built in support for this. You can however create an IDocumentFilter that adds tags:

public class TagsFilter : IDocumentFilter
{
    public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
    {
        if (swaggerDoc.tags == null)
        {
            swaggerDoc.tags = new List<Tag>();
        }
        swaggerDoc.tags.Add(new Tag {name = "pet", description = "Everything about your Pets"});
    }
}

After adding this filter to the config the UI displays the description.