我是 Swagger API 的新手,在 ASP.Net 中也是如此,我想知道如何在 UI 上添加新的 HTTP 方法(例如 GET、POST、PUT、DELETE)。它仅包含 6 个默认方法。我想添加另一个 GET 方法。那么,有什么帮助吗?
控制器
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace DemoSwagger.Controllers
{
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "Cat", "Dog", "Bear" };
}
// GET api/values/5
public string Get(int id, string sm, string BCID)
{
if (id == 1)
{
return "Cat";
}
else if (id == 2)
{
return "Dog";
}
else if (id == 3)
{
return "Bear";
}
else
{
return "Out of Range";
}
}
// POST api/values
public void Post([FromBody]string value)
{
}
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/values/5
public void Delete(int id)
{
}
}
}