I am using swagger 2.0 for my api testing and documentation. My api controllers are using Dispose() method to release unmanaged resources. but swagger is not working for the Dispose method, and giving NotSupportedException: Ambiguous HTTP method for action - ProfileCore.Controllers.UserTypeController.Dispose1 (ProfileCore). Actions require an explicit HttpMethod binding for Swagger 2.0
Swagger Code:
c.SwaggerDoc("v1", new Info { Version = "v1", Title = "Profile Core API", Description = "A simple example ASP.NET Core Web API", TermsOfService = "None", Contact = new Contact { Name = "Profile Core", Email = string.Empty, Url = "https://example.com" }, License = new License { Name = "Use under LICX", Url = "https://example.com/license" } }); c.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Description = "Please enter JWT with Bearer into field", Name = "Authorization", Type = "apiKey" }); c.AddSecurityRequirement(new Dictionary<string, IEnumerable<string>> { { "Bearer", Enumerable.Empty<string>() }, }); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetEntryAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); API Controller:
[ApiController] public class UserTypeController : ControllerBase { #region Fields private readonly IUserTypeBiz _userTypeBiz; #endregion #region Ctor public UserTypeController(IUserTypeBiz userTypeBiz) { _userTypeBiz = userTypeBiz; } #endregion #region Actions /// <summary> /// Get All User Type List /// </summary> /// <returns></returns> [HttpGet("getList")] public IActionResult List() { return Ok(_userTypeBiz.List(null).Value); } #endregion #region Dispose Methods private bool _disposed = false; /// <summary> /// Dispose the UserTypeBiz after finish task /// </summary> /// <param name="disposing">Flag for indicating desposing or not</param> public virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _userTypeBiz.Dispose(); } } _disposed = true; } /// <summary> /// Dispose the UserTypeBiz after finish task /// </summary> public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion }