.net - Net Core 中 "ProducesResponseType"的 .NET 等价物是什么?

标签 .net api .net-core

我必须从使用 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/

相关文章:

c# - 如何使 elmah.io 与 ASP.NET Core 和错误处理中间件良好配合?

c# - 这种签名 URL 的实现是否相当安全?

c# - AsParallel() 或异步/等待

android - api的问题

c# - 在 C# 中实现即发即弃方法的最简单方法?

javascript - 从谷歌表格中的电报机器人输入数据

api - 可以创建自定义界面,利用由 Alfresco 管理的文件吗?

.net-core - NSwag 向所有枚举添加 x-enum-varnames 标签

c# - 您预计 CLR 会很快适应 NUMA 吗?

c# - ASP.NET : How do I fetch data from a webserver every few minutes