swagger,参数,list,swaggerui测试list
在ASP.net、C#、.netfreamwork环境下:
使用swaggerui时,如果入参格式为 List
一、HttpGet示例:
后台示例:
1.经测试,后台List
http://192.168.0.101:9085/api/History/GetDaySignalSummary?summaryList=1&summaryList=2&startTime=2020-03-30&stationId=11010801-6561-41cb-b131-e812f09daab6
///
/// 获取历史数据合计 ///
[ActionsGroup("统计数据获取")]
[HttpGet] public JObject GetSignalSummary([FromUri]List<int> summaryList, string startTime, string endTime, string stationId)
JObject result = new JObject(); try
RedisHelper redisStruct = new RedisHelper((int)EnumUserRedisNum.Struct);
cfg_station station= redisStruct.HashGet(ConstValue.Area, stationId);
history_signalsummaryBLL summaryBLL = new history_signalsummaryBLL();
JObject temp = summaryBLL.GetSignalSummary(station.keycode, summaryList, startTime, endTime); if (temp == null)
result.Add("Code", (int)EnumExecStatus.失败);
result.Add("Error", "未获取到历史数据"); return result;
result.Add("Code", (int)EnumExecStatus.成功);
result.Add("Result", temp);
} catch (Exception ex)
LogEvent.LogInfo.Fatal(ex.ToString());
result.Add("Code", (int)EnumExecStatus.失败);
result.Add("Error", ex.ToString());
} return result;
}
SwaggerUI调用示例:
二、HttpPost示例:
1.经测试,后台List
2.参数格式填写错误:需要填写成如下格式:
["1","2","3"]