When marking one Route
to be Obsolete
, OpenAPI swagger shows all routes are obsolete.
[Route("/api/Items/{Id}/Delete", "Delete"), Obsolete]
[Route("/api/Items/{Id}", "Delete")]
public class DeleteItemRequest : IReturn<ItemsResponse>
{
public long Id { get; set; }
public string Name { get; set; }
}
This declaration marks DeleteItemRequest
with [Obsolete] attribute it does not bind [Obsolete] attribute to particular route, it’s equal to
[Route("/api/Items/{Id}/Delete", "Delete")]
[Obsolete]
[Route("/api/Items/{Id}", "Delete")]
public class DeleteItemRequest : IReturn<ItemsResponse>
{
public long Id { get; set; }
public string Name { get; set; }
}
If you want to mark operation as Obsolete only for particular route, you should use ApiDeclarationFilter to set Deprecated
property to true
for operation Delete
in the paths with key “/api/Items/{Id}/Delete”
Plugins.Add(new OpenApiFeature
{
ApiDeclarationFilter = (api) => {
api.Paths["/api/Items/{Id}/Delete"].Delete.Deprecated = true;
}
});
That’ll work. It’ll be more handy if there is a way to do it within the Route
declaration. Maybe something like [Route("/api/Items/{Id}/Delete", "Delete", Deprecated = true)]