这是我的API:
/// <summary>
/// Gets activity logs.
/// </summary>
/// <param name="locationId">Location id.</param>
/// <param name="filter">Activity log filter options.</param>
[ResponseType(typeof(ActivityLogResponse))]
public async Task<HttpResponseMessage> FetchActivityLogs(int locationId, ActivityLogFilterOptions filter)
{
try
{
var response = await _activityLogLogic.GetActivityLogs(CHIdentity.User, locationId, filter);
return Request.CreateResponse(HttpStatusCode.OK, response);
}
catch (HttpRequestException ex)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message + "\n" + ex.InnerException.Message);
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
}
}
ActivityLogResponse
类的定义:
public class ActivityLogResponse
{
public List<ActivityLogMessage> ActivityLogs { get; set; }
Logs { get; set; }
}
招摇的是JSON 回复 "type": "object"
而不是ActivityLogFilterOptions
请参阅以下Swagger Json中的Responses
:
"/api/locations/{locationId}/FetchActivityLogs": {
"post": {
"tags": ["ActivityLog"],
"summary": "Gets activity logs.",
"operationId": "ActivityLog_FetchActivityLogs",
"consumes": ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"],
"produces": ["application/json", "text/json", "application/xml", "text/xml"],
"parameters": [{
"name": "locationId",
"in": "path",
"description": "Location id.",
"required": true,
"type": "integer",
"format": "int32"
}, {
"name": "filter",
"in": "body",
"description": "Activity log filter options.",
"required": true,
"schema": {
"$ref": "#/definitions/ActivityLogFilterOptions"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object"
}
}
}
}
},
如何在此处加载ActivityLogFilterOptions
而不是{}
?