JSON API 过滤包含的资源

JSON API filter included resources

问题是关于 JSON API 规范以及如何正确执行请求 (我在 rails 和 json api 资源 gem 上使用 ruby 但无论如何这是一个普遍的问题,我知道如何实现它,我只是想要遵守 JSON API 的规则:http://jsonapi.org/format/)

情况一:

情况二:

为包含未读图书的所有书架设计请求的正确方法是什么?

想不通这个

www.library.com/shelves?include=books&filter[books.unread]=true ?

www.library.com/shelves?include=unread_books? <- 必须指定另一个资源,未读的书

www.library.com/shelves?filter[books.unread]=true ?

最正确的做法是什么?

编辑

在与我的技术负责人和其他几个程序员交谈后,在这种情况下第一个选项最受青睐

我会赌第一个:

www.library.com/shelves?include=books&filter[books.unread]=true

JSON API目前不支持过滤包含,但这并不意味着你必须严格定义(检查https://github.com/cerebris/jsonapi-resources/issues/314

我会采用与 brian 相同的方法: www.library.com/shelves?include=books&filter[books.unread]=true

我只是想为答案提供更多背景信息。