-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Description
In version 9.0.7 of Microsoft.AspNetCore.OpenApi, it was possible to order tags using an IOpenApiDocumentTransformer, that is no longer possible as of 10.0.0-preview.6.25358.103.
Version 9.0.7 document transformer:
using Microsoft.AspNetCore.OpenApi;
using Microsoft.OpenApi;
internal sealed class DocumentOrderTransformer : IOpenApiDocumentTransformer
{
public Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerContext context, CancellationToken cancellationToken)
{
// Order tags alphabetically. Tags containing spaces are replaced with
// "s " before sorting so multi word tags come after single word tags.
// This quirk is intentional to keep the generated document easier to
// read.
if (document.Tags is not null)
document.Tags = document.Tags
.OrderBy(tag => tag.Name.Replace(" ", "s "))
.ToList();
// Order paths alphabetically
var orderedPaths = new OpenApiPaths();
foreach (var kvp in document.Paths.OrderBy(kvp => kvp.Key))
orderedPaths.Add(kvp.Key, kvp.Value);
document.Paths = orderedPaths;
return Task.CompletedTask;
}
}
Version 10.0.0-preview.6.25358.103 document transformer changed Tags
to be an ISet<OpenApiTag>
.
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi