【问题标题】:ServiceStack IReturn and metadataServiceStack IReturn 和元数据
【发布时间】:2012-10-05 06:11:30
【问题描述】:

有趣的是,在实现和不实现 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 和双待办事项。

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{
}
//-----------------------------------------
......

【问题讨论】:

    标签: c# .net rest servicestack


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-07
      相关资源
      最近更新 更多