c# - Swashbuckle - 同一端点生成多个 operationId
问题描述
在 .NET 4.8 WebApi 应用程序中,我有一个简单的控制器,例如
[Authorize]
public class AccountController : WebApiBaseController
{
[AllowAnonymous]
[HttpPost]
public async Task<IHttpActionResult> RequestPasswordReset([FromUri]string email)
{
await RequestPasswordReset(email);
return Ok();
}
}
当我使用 swashbuckle 生成 api 规范时,它会为此创建多个操作。
"/api/Account/RequestPasswordReset": {
"post": {
"tags": [ "Account" ],
"operationId": "Account_RequestPasswordReset",
"consumes": [],
"produces": [ "application/json", "text/json", "application/xml", "text/xml" ],
"parameters": [
{
"name": "email",
"in": "query",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": { "type": "object" }
}
}
}
},
但然后在我的规格中降低
"/api/Account": {
"post": {
"tags": [ "Account" ],
"operationId": "Account_RequestPasswordReset",
"consumes": [],
"produces": [ "application/json", "text/json", "application/xml", "text/xml" ],
"parameters": [
{
"name": "email",
"in": "query",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": { "type": "object" }
}
}
}
},
如何使它不为同一个端点生成 2 个操作?
解决方案
推荐阅读
- windows - 如何在 Windows 上正确存储进程 ID (PID)
- binary - 将十进制数 7710 转换为 8 位二进制二进制补码
- azure - 如何将 Xamarin 表单应用与 Azure Directline 语音机器人集成?
- php - PHPMailer - 如何禁用 SMTPDebug?
- tableau-api - 如何关闭筛选器的 Tableau 自动更新
- firebase - Flappy 搜索栏:实现搜索
- python - 合并两个不相等的数据框
- c# - 如何一次从一对多关系的表中删除 ASP .NET Core 中的多行?
- c - 在 Windows 终端中使用 GDB 有困难。GDB 在运行程序后自行退出,无需等待我的进一步命令
- swift - 像最近一样在iphone中向上滚动隐藏标题 - swiftUI