重新安装API客户端 - 在单个对象中混合主体和查询型物
当使用REFIT REST库来构建针对基于ASP.NET API的客户端时,是否可以将查询和主体项目混合在单个自定义对象中?
示例ASP.NET路由示例
[Route("documents/{id}")]
public void PostDocument(int id, [FromBody] document)
示例示例REFIT客户端和请求对象,显示单个对象中的正文和查询定义的所需混合
[Post("/documents/{document.id}")]
Task PostDocument(PostDocumentRequest request);
public class PostDocumentRequest
{
public int Id { get;set; }
public [Query] DateTime? LocalDateTime { get;set; }
public [Body] Document Document { get;set; }
}
When using the Refit REST Library to build a client targeting an asp.net based api is it possible to mix Query and Body items in a single Custom Object?
Example Asp.Net Route
[Route("documents/{id}")]
public void PostDocument(int id, [FromBody] document)
Example Refit Client and Request Object showing desired mixing of Body and Query definition in single object
[Post("/documents/{document.id}")]
Task PostDocument(PostDocumentRequest request);
public class PostDocumentRequest
{
public int Id { get;set; }
public [Query] DateTime? LocalDateTime { get;set; }
public [Body] Document Document { get;set; }
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论