2017-04-05 77 views
-1

我有一個Web API(WebApi 2)。我正在嘗試使用Swashbuckle進行文檔編制。我有一個GET方法,它將List作爲參數。該方法的工作原理,但沒有出現在Swashbuckle文檔中。Swashbuckle不顯示具有作爲參數的集合的方法

[RoutePrefix("myroute")] 
public class MyController : ApiController 
{ 
    [HttpGet] 
    [Route("{foo}/{bar}")] 
    public async Task<IHttpActionResult> Get([FromUri]List<string> foo, string bar) 
    {    
     return Ok(); 
    } 
} 

如何獲得一個List或數組來處理Swashbuckle?

UPDATE

這是我昂首闊步配置:

public class SwaggerConfig 
{   
    public static void Register(HttpConfiguration config) 
    { 
     var thisAssembly = typeof(SwaggerConfig).Assembly; 

     config 
      .EnableSwagger(c => 
       {       
        c.SingleApiVersion("v1", "ZipCodeWebApi.API");       
        c.IncludeXmlComments(string.Format(@"{0}\App_Data\ZipCodeWebApi.API.XML", System.AppDomain.CurrentDomain.BaseDirectory));       
        c.DescribeAllEnumsAsStrings();      
       }) 
      .EnableSwaggerUi(c => 
       {       
       }); 
    } 
} 
+0

直到你在你的webapi路由中做出改變,它纔會顯示在大搖大擺,因爲這不是一個有效的路線。 –

回答

0

因爲你已經說[FromUri],您的操作方法將在招搖顯示只有當你刪除路由屬性。

 [HttpGet] 
     public async Task<IHttpActionResult> Get([FromUri]List<string> foo, string bar) 
     { 
      return Ok(); 
     } 
+0

沒有骰子。我張貼我的swagger配置 –

+0

你的API定義是錯誤的,這就是它沒有顯示的原因。您應該瞭解路由以及參數路由在WEB API中的工作原理。 –

+0

不,路由工作。控制器上有一個路由前綴,我可以使用這個API方法。它只是沒有出現在Swagger中。查看我的更新 –

相關問題