Asp.net web api 使用swashbuckle的多个前置条件注释失败

Asp.net web api 使用swashbuckle的多个前置条件注释失败,asp.net-web-api,swashbuckle,Asp.net Web Api,Swashbuckle,我用它来记录我的web api项目,我不能为预处理失败的案例添加多个响应,swagger只显示最后一个 /// <response code="200">OK</response> /// <response code="401">Unauthorized</response> /// <response code="400">BadRequest</response> /// <response code="412"

我用它来记录我的web api项目,我不能为预处理失败的案例添加多个响应,swagger只显示最后一个

/// <response code="200">OK</response>
/// <response code="401">Unauthorized</response>
/// <response code="400">BadRequest</response>
/// <response code="412">ErrorCode = 1... </response>
/// <response code="412">ErrorCode = 2... </response>
/// <response code="412">ErrorCode = 3... </response>
我希望看到:

{
  ...
  "412": {
    "description": "ErrorCode = 1..."
  },
  "412": {
    "description": "ErrorCode = 2..."
  },
  "412": {
    "description": "ErrorCode = 3..."
  }
}
有什么想法吗


提前感谢

您试图通过Swashback实现的目标是不可能的,因为它不符合开放式API规范(也称为Swagger)。responses对象包含可能的响应列表。每个响应都有一个名称和一个名称。名称可以是
默认值
或HTTP状态代码。根据a的规范,每个状态代码只能有一个响应对象:

任何HTTP状态代码都可以用作属性名称(每个HTTP状态代码一个属性)。描述该HTTP状态代码的预期响应


尽管如此,我怀疑在412响应中添加额外的错误代码是否正确。如果代理服务器已经知道条件不匹配,则条件请求可能无法到达您的服务器

谢谢@venerik,根据您的回答,我最终在描述字段中有一个包含所有可能情况的错误代码条目,并增强了swagger ui,它有一个IOperationFilter来显示每个错误的换行符。
{
  ...
  "412": {
    "description": "ErrorCode = 1..."
  },
  "412": {
    "description": "ErrorCode = 2..."
  },
  "412": {
    "description": "ErrorCode = 3..."
  }
}