michiel / jsonapi-rust

Rust library for serialization, deserialization and working with JSON-API data
MIT License
109 stars 30 forks source link

Nested relations' relations become attributes instead of relations #55

Open mmstick opened 5 years ago

mmstick commented 5 years ago

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",
                        }
                    }
                }
            ]
        }
    }
}
JadedEvan commented 4 years ago

@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.