0
我有Swagger和C#的問題。我有一個GET metod,它接收一個字符串列表,我用Swagger證明它。當我運行應用程序時,在Swagger中,參數「Lista」是paramType = body
而不是query
,調試器在此字段中接收到空值。我該怎麼做?由於Swagger - 在C中的字符串列表#
揚鞭輸出:
Parameter Value Description Parameter Type Data Type
fecha (required) Fecha query date-time
lista Lista body array[string]
C#代碼:
/// <summary>
/// Recover some data
/// </summary>
/// <param name="fecha">Fecha</param>
/// <param name="lista">Lista</param>
/// <returns>Information</returns>
[Route("v1/tareas")]
[SwaggerTags("Planificador")]
[SwaggerResponse(HttpStatusCode.OK, typeof(Tarea))]
[SwaggerResponse(HttpStatusCode.NotFound, typeof(string))]
//[BearerAuthorizeAttribute]
[HttpGet]
public HttpResponseMessage GetTarea(DateTime fecha, List<string> lista = null)
{...}
您應該從屬性[FromBody]中從body獲取參數,或者將參數添加到路由。現在我不確定即使你的DateTime也能工作。 –
字段DateTime工作正常,我總是收到一個日期。問題出在列表上。 – Aw3same
嘗試寫入(...,[FromBody] List lista ... –