Relationships to external (unmanaged) entities

Currently working on improving a service for product information. One facet that is causing some discussion is around associating asset to a product - like images or instruction manuals.

We do have a separate service that handles such files and current we crate relationships to those using a relationship object:

{
    "files": [{"data": {"type": "files","id": "anID"}},...]
}

These assets can be managed within the system and included in responses…

We are looking at allowing external files to be related to an entity, from a CDN or such forth that we do not have any control over.

Initially we thought of the validity of using a links object as the relationship - but this appears to be invalid as per the specification but something like:

{
    "files": [
        {"data": {"type": "files","id": "anID"}},
        ...,
        {"link": { "href": "path_to_external_resource"}}
    ]
}

Looking for suggestions as to how to relate external resources - if it is even valid - or should we look to use meta data on the entity to achieve such things.

Did you considered using an attribute, which value is a URL to fetch the file? That’s how I usually address such use cases. E.g. you may have a file resource, which has a downloadUrl attribute additionally to name, createdAt, updatedAt and similar attributes.

You may also want to have a look at this question, which seems to be similar.

It sounds like the same issue, @jelhan. I’ll post there the project I’ve mentioned since it may help others and because it’s open source. @cheeryfella, go to this other threat, I’ll post there a solution that may serve as inspiration for you.

1 Like