在我的ASP.NET Core应用中,我正在使用NSwag来生成我的swagger.json文件。
当我构建项目时,遇到了如下错误:
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "dotnet
".nuget\packages\nswag.msbuild\13.20.0\buildTransitive../tools/Net70/dotnet-nswag.dll"
run aspnetcoretoopenapi.json
/variables:"input=\src\ApiGateway.Api\ApiGateway.Api.csproj,output=\src\ApiGateway.Api../swagger/ApiGateway.Api.json,configuration=Debug,documentName=Public
API"" exited with code
-1.
ApiGateway.Api \src\Cat.Infrastructure\Build\CreateSwaggerDocument.targets</p>
我的控制器代码如下:
[ApiController]
[Route("v1/[controller]")]
public class MyController : MyControllerBase
{
[HttpGet("{id}/result")]
public async Task<IActionResult> Get([FromRoute] int id)
{
return await ForwardRequest(HttpMethod.Get,
"http://localhost/v2/result");
}
}
public class MyControllerBase : ControllerBase
{
public async Task<IActionResult> ForwardRequest(HttpMethod httpMethod, string url, object? body = null)
{
// do something.
}
}
当我在MyController
中直接放置“ForwardRequest”方法的逻辑,并移除继承关系时,一切都能正常运作。
但当我开始使用MyControllerBase
类时,功能就失效了。
我忽略了什么呢?