Does this json meet the specification?

I have a doubt with this json:

 {
    "data": {
        "type": "matches",
        "id": "day1-101",
        "attributes": {
            "mat": 1,
            "number": "101",
            "phase": "R16"
        },
        "relationships": {
            "refereeAssignment": {
                "data": {
                    "type": "match-referee-assignments",
                    "id": "c60d4e8d-ee83-4a84-9ca1-5a42db5a4c8b"
                }
            },
            "homeCompetitor": {
                "data": {
                    "type": "competitors",
                    "id": "WT-119-1"
                }
            },
            "awayCompetitor": {
                "data": {
                    "type": "competitors",
                    "id": "WT-029-1"
                }
            },
            "results": {
                "data": []
            }
        },
        "links": {
            "self": "https://test-wt02-f.martial.services/ovr/matches/day1-101"
        }
    },
    "included": [
        {
            "type": "participants",
            "id": "IR-1",
            "attributes": {
                "licenseNumber": "IR-1",
                "givenName": "Manley",
                "familyName": "ROMAGUERA",
                "passportGivenName": "MANLEY KAIA",
                "passportFamilyName": "ROMAGUERA",
                "preferredGivenName": "Manley",
                "preferredFamilyName": "ROMAGUERA",
                "printName": "ROMAGUERA Manley",
                "printInitialName": "ROMAGUERA Manley",
                "tvName": "Manley ROMAGUERA",
                "tvInitialName": "M. ROMAGUERA",
                "scoreboardName": null,
                "gender": null,
                "birthDate": "2001-01-27",
                "mainRole": "REFEREE",
                "country": "MEX"
            },
            "relationships": {
                "organization": {
                    "data": {
                        "type": "organizations",
                        "id": "29d82500-d1bb-4502-94f4-b735dee2d915"
                    }
                }
            }
        },
        {
            "type": "participants",
            "id": "IR-2",
            "attributes": {
                "licenseNumber": "IR-2",
                "givenName": "Shayne",
                "familyName": "WINTHEISER",
                "passportGivenName": "SHAYNE EMMETT",
                "passportFamilyName": "WINTHEISER",
                "preferredGivenName": "Shayne",
                "preferredFamilyName": "WINTHEISER",
                "printName": "WINTHEISER Shayne",
                "printInitialName": "WINTHEISER Shayne",
                "tvName": "Shayne WINTHEISER",
                "tvInitialName": "S. WINTHEISER",
                "scoreboardName": null,
                "gender": null,
                "birthDate": "1991-03-20",
                "mainRole": "REFEREE",
                "country": "DEN"
            },
            "relationships": {
                "organization": {
                    "data": {
                        "type": "organizations",
                        "id": "29d82500-d1bb-4502-94f4-b735dee2d915"
                    }
                }
            }
        },
        {
            "type": "participants",
            "id": "IR-3",
            "attributes": {
                "licenseNumber": "IR-3",
                "givenName": "Meagan",
                "familyName": "MAGGIO",
                "passportGivenName": "MEAGAN ROSLYN",
                "passportFamilyName": "MAGGIO",
                "preferredGivenName": "Meagan",
                "preferredFamilyName": "MAGGIO",
                "printName": "MAGGIO Meagan",
                "printInitialName": "MAGGIO Meagan",
                "tvName": "Meagan MAGGIO",
                "tvInitialName": "M. MAGGIO",
                "scoreboardName": null,
                "gender": null,
                "birthDate": "1992-08-24",
                "mainRole": "REFEREE",
                "country": "SWE"
            },
            "relationships": {
                "organization": {
                    "data": {
                        "type": "organizations",
                        "id": "29d82500-d1bb-4502-94f4-b735dee2d915"
                    }
                }
            }
        },
        {
            "type": "match-referee-assignments",
            "id": "c60d4e8d-ee83-4a84-9ca1-5a42db5a4c8b",
            "relationships": {
                "match": {
                    "data": {
                        "type": "matches",
                        "id": "day1-101"
                    }
                },
                "refJ1": {
                    "data": {
                        "type": "participants",
                        "id": "IR-1"
                    }
                },
                "refJ2": {
                    "data": {
                        "type": "participants",
                        "id": "IR-2"
                    }
                },
                "refJ3": {
                    "data": {
                        "type": "participants",
                        "id": "IR-3"
                    }
                }
            }
        }
    ]
}

I thought that for a resource to be displayed within “included” it must also be in “relationships”. In this case there is no resource “participants” within relationships then, Does this Json meet the specifications?

https://www.jsonschemavalidator.net/ says yes, so the response seems to have the right shape.

I think the spec is a bit vague about this, but after reading through it a few times I think this having included resources that are not related to either primary data (your “matches/day1-101”) or to each other is not allowed. :confused:

Maybe you can change your primary data to be an array that consits of “matches/day1-101” AND “organizations/29d82500-d1bb-4502-94f4-b735dee2d915” – But that might be a bit odd. :man_shrugging:

https://jsonapi.org/format/1.1/#document-compound-documents

1 Like

The document requires full linkage, but…

If the URL query parameters have the parameter fields[type] set to a list of fields that do not include at least one of the relationships used by include, then the linkage cannot be seen in the document although it is legal and even mentioned in the specification.

The only exception to the full linkage requirement is when relationship fields that would otherwise contain linkage data are excluded via sparse fieldsets.

https://jsonapi.org/format/#document-compound-documents

To your question, I would answer that it is valid if matches have a relationship that points to some participants (the ones included) and the reason it does not show up is because it was not mentioned in the fields[matches] parameters.

1 Like