'JSONAPI: is it correct to have different types in data[]?

is it correct to have different types in data array ? didn't found answer in specification, but looks wrong.

{
  "data": [
    {
      "type": "type1",
      "id": "id1"
    },

    {
      "type": "type2",
      "id": "id2"
    }
  ]
}


Solution 1:[1]

Polymorphic collections are supported by JSON:API specification. Your example is a valid JSON:API document.

This is not mentioned explicitly in the specification. It is only implicitly stated by not requiring all resource objects included as primary data to have the same type.

Please note that it could even include two resource objects with the same id as long as they have different type.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jelhan