有趣的是,无论是否实施IReturn,元显示都会有所不同。 当实施IReturn时,我想知道如何构建DTO以修剪元数据输出?
代码
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和double Todos。
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{
}
//-----------------------------------------
......
答案 0 :(得分:3)
使用New API的元数据页面已在HEAD版本的ServiceStack中修复。您现在可以分叉repo,否则将在周末部署新版本的ServiceStack。