loopbackio / loopbackio/loopback-next
item-and-collection hypermedia-schemas
Ouverte
@achrinza y travaille déjà.
Depuis le 20/9/2020.
Extensions
feature
- Langage dominant
- TypeScript
- Étoiles
- 5.1k
- Forks
- 1.1k
- Merge moyen
- 2 j 21 h
- PR mergées (30 j)
- 27
Description
Providing generic item & collection hypermedia-schemas
- item-schema with links like: [self,item,update,delete]
- 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
- reference item/collection-schema in custom mime-type
- unify access to docs and validation schemas
- have generic API-Browser
Item Schema example
curl -i http://example.org/api/item-schemas/people
{
"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
{
"$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*}"
}
]
}
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Évaluation
Cette issue n'a pas encore été évaluée.