Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WEB API的文档框架';s_Api_Rest_Asp.net Web Api - Fatal编程技术网

WEB API的文档框架';s

WEB API的文档框架';s,api,rest,asp.net-web-api,Api,Rest,Asp.net Web Api,我正在使用来记录我的API,但我正在寻找另一种工具,它允许我的API具有多个具有相同动词+路径的“方法”,例如: [RoutePrefix("api/Customer")] public class CustomerController : ApiController { [HttpGet] [Route("")] public ClienteDTO GetCustomerByContractId(int contractId) { //...

我正在使用来记录我的API,但我正在寻找另一种工具,它允许我的API具有多个具有相同动词+路径的“方法”,例如:

[RoutePrefix("api/Customer")]
public class CustomerController : ApiController
{
    [HttpGet]
    [Route("")]
    public ClienteDTO GetCustomerByContractId(int contractId)
    {
        //...
    }

    [HttpGet]
    [Route("")]
    public ClienteDTO GetCustomerByAccountId(int accountId)
    {
        //...
    }
} 
这在ASP.NET WEB API中运行良好,因为“GET”请求将命中服务器端的正确方法:

http://example.com/api/Customer?contractId=1
http://example.com/api/Customer?accountId=1
但斯威格并不支持这一点()


有人知道支持此功能的替代文档框架吗?

Microsoft提供的NuGet软件包没有此限制:

https://www.nuget.org/packages/Microsoft.AspNet.WebApi.HelpPage


它是微软的官方软件,很容易定制,因为它向您的解决方案中添加了文件(一个控制器、一个css和一些cshtml文件)。唯一的问题是,您不能像Swashback中那样对API进行测试调用(我说,直接从文档页面执行POST、GET等)。我对cshtml文件做了一些修改,并很容易地添加了此功能。

这不是设计API的正确方法。这两个API的路径应该是这样的:
API/customer/contract/{id}
API/customer/account/{id}
Ops。。。我注意到这是一个很老的问题。