jsonapi icon indicating copy to clipboard operation
jsonapi copied to clipboard

Allow include in included and data resourses with same id

Open v1t3 opened this issue 1 year ago • 0 comments

Say, I have resource structure like this:

{
    "data": [
        {
            "type": "news",
            "id": "item1",
            "attributes": {
                "title": "item1"
            },
            "relationships": {
                "also": {
                    "data": [{
                            "type": "news",
                            "id": "item2"
                        }]
                }
            }
        },
        {
            "type": "news",
            "id": "item2",
            "attributes": {
                "title": "item2"
            },
            "relationships": {
                "also": {
                    "data": [{
                            "type": "news",
                            "id": "item3"
                        }]
                }
            }
        }
    ]
}

And I want to get resources like this:

{
    "data": [
        {
            "type": "news",
            "id": "item1",
            "attributes": {
                "title": "item1"
            },
            "relationships": {
                "also": {
                    "data": [{
                            "type": "news",
                            "id": "item2"
                        }]
                }
            }
        },
        {
            "type": "news",
            "id": "item2",
            "attributes": {
                "title": "item2"
            },
            "relationships": {
                "also": {
                    "data": [{
                            "type": "news",
                            "id": "item3"
                        }]
                }
            }
        }
    ],
    "included": [
        {
            "type": "other_companies",
            "id": "item2",
            "attributes": {
                "title": "item2",
                "link": "link",
                "code": "item2",
                ...
            }
        }
    ]
}

For now there will be triggered error "can not have multiple resources with the same identification".

Can we add individual id validation for included? Just make another claimUsedResourceIdentifier for included. Or add option for validator.

v1t3 avatar Mar 06 '24 10:03 v1t3