I'm building a Restful API and trying to use JSON:API format for my response. Looking at https://jsonapi.org/format/, it states:
A resource object MUST contain at least the following top-level members:
Exception: The id member is not required when the resource object originates at the client and represents a new resource to be created on the server.
My API will be returning a list of, say, fruits. The list of fruits won't be coming from my database -- it will be collected from an external source. That external source does not give me an
id. Also, I won't be saving the fruit items in my database, so I can't even return an internally generated id for it.
Also, my database won't have a "fruits" table at all -- so I'm even reluctant to use the
In other words, I don't think I can set
type. And if I don't, then my API response is no longer JSON:API compliant.
How do I handle this?