I am using Swaschbuckle for my .NET Swagger Web API Service.
I have looked at the sample from http://petstore.swagger.io/#/pet and there ist the Action findByTags which is crossed out.
I want to cross out an action in my api service, but when i am using the obsolete attribute the action isn't visible.
Any idea how to handle this issue?
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.
Firstly, the cURL command is for display and copy-pasting only. Swagger UI does not actually use cURL for requests – it's a web page so it makes requests using JavaScript (fetch API or XMLHttpRequest or similar).
I had the same problem with my WebApi project, but after updating Swashbuckle.Core nuget package to version 5.6.0 it started to work.
I have a SwaggerConfig class that looks like this:
public static class SwaggerConfig
{
public static void Register(HttpConfiguration configuration)
{
configuration.EnableSwagger(Configure).EnableSwaggerUi(ConfigureUi);
}
static void Configure(SwaggerDocsConfig config)
{
config.SingleApiVersion("V1", "MichalBialecki.com.Swagger.Example");
config.UseFullTypeNameInSchemaIds();
}
static void ConfigureUi(SwaggerUiConfig config)
{
config.DocExpansion(DocExpansion.None);
config.DisableValidator();
}
}
You also need to register it in Startup.cs:
SwaggerConfig.Register(config);
And with method in ApiController like this:
[HttpGet]
[Obsolete("This method is obsolete, please use /accounts/{accountId}")]
[Route("personalAccount/{accountId}")]
public AccountDTO GetPersonalAccount(int accountId)
I can see in Swagger, that it is stroked out:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With