jsonapi-rust icon indicating copy to clipboard operation
jsonapi-rust copied to clipboard

Nested relations' relations become attributes instead of relations

Open mmstick opened this issue 6 years ago • 1 comments

Instead of creating something like this:

"data": {
    "type": "inventory-purchase-order",
    "attributes": {
        "purchase-order-lines": [
            {
                "parts": [],
                "price": "99.99",
                "purchase-order": null,
                "purchased-quantity": 1,
                "sku": {
                    "assembly-configurations": [],
                    "description": null,
                    "id": "21",
                    "kind": "case",
                    "manufacturer": null,
                    "reorder-quantity": 0,
                    "serialized": false,
                    "sku": "RCV-TEST-0001"
                }
            }
        ],
    },
    "relationships": {
        "purchase_order_lines": {
            "data": [
                {
                    "type": "inventory-purchase-order-line",
                }
            ]
        }
    }
},

It should create this:

"data": {
    "type": "inventory-purchase-order",
    "relationships": {
        "purchase-order-lines": {
            "data": [
                {
                    "meta": {
                        "attributes": {
                            "price": "99.99",
                            "sku-id": "21",
                        }
                    }
                }
            ]
        }
    }
}

mmstick avatar Dec 20 '18 17:12 mmstick

@mmstick do you have an example of some code that you used to generate this? Happy to explore this issue if you can help provide an example that demonstrates how you arrived at the invalid document.

JadedEvan avatar Jan 24 '20 04:01 JadedEvan