如何解决重新生成后如何重用域代码
在我看来,由 OpenAPI 生成器为 aspnetcore 服务器代码生成的存根是必须填充实际域代码的示例:
/// <summary>
/// List of open Cycles
/// </summary>
/// <response code="200">List of open Cycles</response>
[HttpGet]
[Route("/mcr/v1/cycle/list")]
[ValidateModelState]
[SwaggerOperation("CyclesListCycles")]
[SwaggerResponse(statusCode: 200,type: typeof(List<MCycle>),description: "List of open Cycles")]
public virtual IActionResult CyclesListCycles()
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(),return this.BadRequest(..),...
// return StatusCode(200,default(List<MCycle>));
string exampleJson = null;
exampleJson = "{\n \"pa\" : \"pa\",\n \"workcenter\" : \"workcenter\",\n \"id\" : 0,\n \"sn\" : \"sn\",\n \"taskid\" : \"taskid\"\n}";
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<MCycle>>(exampleJson)
: default(List<MCycle>);
//TODO: Change the data returned
return new ObjectResult(example);
}
我想或多或少除了返回语句之外的所有内容都必须被替换以实现方法的实际行为。
再次运行生成器时,它将覆盖所有内容。
现在我想知道是否有建议的方法或最佳实践来处理这种情况。我的第一次尝试是使用这些存根中的实际域代码调用方法。然而,即使这样,特定的修改也需要在重新生成后再次进行,因此很难实现自动化。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。