Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Root tags object not showing
I set the attribute [Tags("...")] in the Controler and despite having my openapi.json object with tags under the designated methods, eg:
"paths": { "/sessions": { "post": { "tags": [ "Authentication Session" ], "summary": "Create a session",
The root object tags is not created. Any idea what's missing ?
I'm not familiar with the TagsAttribute
you're referring to. Could you please provide more info (sample code, expected output etc.).
Hello, either the [Tags("Session")] from Microsoft.AspNetCore.Http or [SwaggerOperation(Tags = new[] { "Session" }] from Swashbuckle.Swagger.Annotations
And they work in some instance since they are able to get appended to the method information "paths": { "/sessions": { "post": { "tags": [ "Session" ], "summary": "Create a session",
But the array tags at the root level object, that encompasses all the tags available in the api, remains empty. I did a workaround where I create a IDocumentFilter
and fill the array swaggerDoc.Tags
by hand.. But I shouldn't have to do this right ?
Hello, please see the linked PR https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/2565 that adds support for the TagsAttribute
- let me know if this would be helpful for resolving your issue, or if you had a different approach to implementing a workaround @greg-signi?
Hi, any update for ” the array tags at the root level object, that encompasses all the tags available in the api, remains empty“ ?
Solved with:
using System.Linq;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
public class SwaggerTagsFilter : IDocumentFilter
{
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
swaggerDoc.Tags = swaggerDoc.Paths.SelectMany(p => p.Value.Operations)
.SelectMany(o => o.Value.Tags)
.Select(t => t.Name)
.Where(g => !string.IsNullOrWhiteSpace(g))
.Select(name => new OpenApiTag { Name = name })
.ToList();
}
}
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/2565#issuecomment-2053577323
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
This issue was closed because it has been inactive for 14 days since being marked as stale.