aimeos / ai-client-jsonapi

Aimeos frontend JSON API
GNU Lesser General Public License v3.0
28 stars 6 forks source link

Inconsistent links.self #14

Closed exemplari closed 2 years ago

exemplari commented 2 years ago

The attribute "links.self" are inconsistent across domains. Besides "Self" the other attributes always provide an object with href and methods. Only with the "self" of links an object is inconsistent.

Some domains don't provide this link object for the "self", just a string (Product or Customer). Other domains like Basket do provide a link object.

Fetch a Catalog https://aimeos.org/docs/2021.x/frontend/jsonapi/catalog/#fetch-products

{
    "meta": {
        "total": 3
    },
    "links": {
        "self": "http:\/\/localhost:8000\/jsonapi\/product?include=attribute%2Cmedia%2Cprice%2Cproduct%2Cproduct%2Fproperty%2Ctext&page%5Boffset%5D=0"
    },

vs

Fetch a Basket https://aimeos.org/docs/2021.x/frontend/jsonapi/baskets/#fetch-the-basket


{
    "meta": {
        "total": 1,
        "prefix": null,
        "content-baseurl": "/",
        "csrf": {
            "name": "_token",
            "value": "..."
        }
    },
    "links": {
        "self": {
            "href": "http://localhost:8000/jsonapi/basket",
            "allow": ["DELETE","GET","PATCH"]
        }
aimeos commented 2 years ago

Yes, self only contains allow if other than GET method is allowed, otherwise it's only a simple URL. This is in line with the JSON:API standard: https://jsonapi.org/format/#document-links

exemplari commented 2 years ago

ok