loopbackio / loopbackio/loopback-next
item-and-collection hypermedia-schemas
@achrinza がすでに取り組んでいます。
2020年9月20日 から。
- 主要言語
- TypeScript
- スター
- 5.1k
- フォーク
- 1.1k
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 27
説明
## Providing generic item & collection hypermedia-schemas
1. item-schema with links like: [self,item,update,delete]
2. collection-schema with links like: [self,add,"paginate"], $ref: [item-schema]
Idea + solution from here (lb3) :
https://www.npmjs.com/package/loopback-jsonschema#item-and-collection-schemas
Metadata might be served from /schemas/ or /item-schemas/ -endpoint - and allow CRUD
## Use Cases
1. reference item/collection-schema in custom mime-type
2. unify access to docs and validation schemas
3. have generic API-Browser
## Item Schema example
`curl -i http://example.org/api/item-schemas/people`
```js
{
"id": "537530ea27f8870b63f2d886",
"type": "object",
"title": "Person",
"collectionTitle": "People",
"collectionName": "people",
"links": [
{
"rel": "self",
"href": "http://example.org/api/people/{id}"
},
{
"rel": "item",
"href": "http://example.org/api/people/{id}"
},
{
"rel": "update",
"method": "PUT",
"href": "http://example.org/api/people/{id}"
},
{
"rel": "delete",
"method": "DELETE",
"href": "http://example.org/api/people/{id}"
}
],
"$schema": "http://json-schema.org/draft-04/hyper-schema#"
}
```
## collection Schema example
`curl -i http://example.org/api/collection-schemas/people`
```js
{
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
"title": "People",
"type": "array",
"items": {
"$ref": "http://example.org/api/item-schemas/people"
},
"links": [
{
"rel": "self",
"href": "http://example.org/api/people"
},
{
"rel": "add",
"method": "POST",
"href": "http://example.org/api/people",
"schema": {
"$ref": "http://example.org/api/item-schemas/people"
}
},
{
"rel": "previous",
"href": "http://example.org/api/people?filter[limit]={limit}&filter[offset]={previousOffset}{&paginateQs*}"
},
{
"rel": "next",
"href": "http://example.org/api/people?filter[limit]={limit}&filter[offset]={nextOffset}{&paginateQs*}"
},
{
"rel": "page",
"href": "http://example.org/api/people?filter[limit]={limit}&filter[offset]={offset}{&paginateQs*}"
},
{
"rel": "order",
"href": "http://example.org/api/people?filter[order]={orderAttribute} {orderDirection}{&orderQs*}"
}
]
}
```
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。