Any way to mark a endpoint Obsolete or Deprecated?

Hi,

Is there a way to mark a endpoint obsolete or deprecated that shows in swagger?

There is no special attribute which can mark service endpoint to show it as deprecated in swagger schema, but you can use OperationFilter action when register SwaggerFeature to modify swagger declarations and set Deprecated property to string “true” for obsolete methods.

For example,

Plugins.Add(new SwaggerFeature { 
    OperationFilter = op => op.Deprecated = (op.Nickname == typeof(MyObsoleteEndpoint).Name) ? "true" : null 
});

I added automatically marking swagger operation as deprecated if DTO has got [Obsolete] attribute in this commit and this change is available from v4.5.7 and is deployed to MyGet

Example:

[Obsolete]
[Route("/deprecated-operation")]
public class DeprecatedOperation : IReturn<string>
{
  //DTO members go here
}
1 Like

Much appreciated. When is next release due?

we’re aiming for this week.