gpt4 book ai didi

c# - ServiceStack IReturn 和元数据

转载 作者:行者123 更新时间:2023-11-30 22:24:35 25 4
gpt4 key购买 nike

有趣的是,在实现和不实现 IReturn 的情况下,元数据显示有所不同。实现 IReturn 后,我想知道如何构建 DTO 来修剪元数据输出?

enter image description here

代码

namespace Backbone.Todos {
//Without IReturn --------------------------
[Route("/todos","POST")] //add
[Route("/todos/{id}","POST")] //edit
public class Todo {
public long Id { get; set; }
public string Content { get; set; }
public int Order { get; set; }
public bool Done { get; set; }
}
//-----------------------------------------
[Route("/todos","GET")] //list
public class TodoList {
}
//-----------------------------------------
[Route("/todos/{id}","DELETE")]//delete
public class DeleteTodo {
public int Id { get; set; }
}
//-----------------------------------------
[Route("/todos/reset")] //reset
public class ResetTodos {
}

……

现在相同,但使用 IReturn<>,元数据看起来很奇怪。注意图中的 List`1 和双待办事项。

namespace Backbone.Todos {
//Implementing IReturn---------------------
[Route("/todos","POST")] //add
[Route("/todos/{id}","POST")] //edit
public class Todo : IReturn<Todo> {
public long Id { get; set; }
public string Content { get; set; }
public int Order { get; set; }
public bool Done { get; set; }
}
//-----------------------------------------
[Route("/todos","GET")] //list
public class TodoList : IReturn<List<Todo>> {
}
//-----------------------------------------
[Route("/todos/{id}","DELETE")]//delete
public class DeleteTodo : IReturnVoid {
public int Id { get; set; }
}
//-----------------------------------------
[Route("/todos/reset")] //reset
public class ResetTodos : IReturnVoid{
}
//-----------------------------------------
......

最佳答案

使用新 API 的元数据页面已经在 ServiceStack 的 HEAD 版本中修复。您现在可以 fork 该存储库,否则将在周末部署新版本的 ServiceStack。

关于c# - ServiceStack IReturn 和元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12740488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com