修复异步控制器返回模型配置的错误。

This commit is contained in:
falcon 2022-04-20 11:10:39 +08:00
parent 13cdd46180
commit 4aa3936754

View File

@ -28,8 +28,8 @@ namespace Falcon.SugarApi.ApiDefinistions
}
var art = action.ActionMethod.ReturnType;
Type returnType =
art.IsGenericType && art.IsAssignableFrom(typeof(Task<>)) ? art.GenericTypeArguments[0].GetGenericArguments()[0] :
art;
art.IsGenericType && art.GetGenericTypeDefinition() == typeof(Task<>) ?
art.GenericTypeArguments[0] : art;
action.Filters.Add(new ProducesResponseTypeAttribute(returnType, StatusCodes.Status200OK));
action.Filters.Add(new ProducesResponseTypeAttribute(typeof(ExceptionModel), StatusCodes.Status400BadRequest));
}