VERSION:
Swashbuckle.AspNetCore and Swashbuckle.AspNetCore.Newtonsoft of version 6.8.1
STEPS TO REPRODUCE:
I have created a controller and the web api method as below,
[ApiController]
public class CustomApiController : Microsoft.AspNetCore.Mvc.Controller
{
[HttpPost]
[Route("api/custom/search")]
public JsonResult CustomSearch(CustomSearchRequest request)
{
....
....
return JsonResult(object)
}
}
In Startup.cs
ConfigureServices Method:
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(options =>
{
options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
});
In Configure method:
app.UseSwagger();
app.UseSwaggerUI();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(name: "Default", pattern: "{controller}/{action}/{id?}"); // Default controllers
endpoints.MapControllers(); // Attribute Routing
endpoints.MapControllerRoute(
name: "CustomSearch",
pattern: "api/custom/search",
defaults: new { controller = "CustomApi", action = "CustomSearch" }
);
}
EXPECTED RESULT:
The API endpoint is not shown in swagger UI
ACTUAL RESULT:
It shows all other APIs from the library. The custom API needs to be listed in the Swagger UI.
VERSION:
Swashbuckle.AspNetCore and Swashbuckle.AspNetCore.Newtonsoft of version 6.8.1
STEPS TO REPRODUCE:
I have created a controller and the web api method as below,
[ApiController]
public class CustomApiController : Microsoft.AspNetCore.Mvc.Controller
{
[HttpPost]
[Route("api/custom/search")]
public JsonResult CustomSearch(CustomSearchRequest request)
{
....
....
return JsonResult(object)
}
}
In Startup.cs
ConfigureServices Method:
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(options =>
{
options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
});
In Configure method:
app.UseSwagger();
app.UseSwaggerUI();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(name: "Default", pattern: "{controller}/{action}/{id?}"); // Default controllers
endpoints.MapControllers(); // Attribute Routing
endpoints.MapControllerRoute(
name: "CustomSearch",
pattern: "api/custom/search",
defaults: new { controller = "CustomApi", action = "CustomSearch" }
);
}
EXPECTED RESULT:
The API endpoint is not shown in swagger UI
ACTUAL RESULT:
It shows all other APIs from the library. The custom API needs to be listed in the Swagger UI.