我必须从使用 NET CORE 制作的 API 到 .NET 进行“反向”
我在将 [ProducesResponseType]
从 Net Core 更改为有效的 .NET 时遇到问题
例如我有这段代码:
[ApiExplorerSettings(GroupName = "groupName")]
[ProducesResponseType(typeof(something), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(void), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status500InternalServerError)]
[HttpPost("thing", Name = "creatingThisThing")]
public async Task<IHttpActionResult> PostThing([FromBody]dynamic value)
{
/// Other Stuff
我知道我可以避免使用组名,我可以像这样调整路由:
[HttpPost]
[Route("", Name = "creatingThisThing")]
/// etc
但我想知道我可以用什么来“替代”前面提到的。
希望我说得足够清楚。
最佳答案
我在 .NET 4.6.1 中成功地使用了 System.Web.Http.Description
中的 [ResponseType(typeof(SomeClass))]
。
关于.net - Net Core 中 "ProducesResponseType"的 .NET 等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60011914/