kurierjs / kurier

TypeScript framework to create JSON:API compliant APIs
https://kurier.readthedocs.io/en/latest/
MIT License
61 stars 9 forks source link

Adds support for optional relationships in schema definitions #284

Closed joelalejandro closed 3 years ago

joelalejandro commented 3 years ago

Resolves #232.

Some basic resources, such as classificators (i.e. resources with nothing more than an ID and a name), don't need to have relationships specified.

This PR modifies resourceFor to insert an empty ({}) object for resource.schema.relationships in case the definition doesn't include it.

This change has no impact on the ResourceSchema definition, since relationships will continue to be mandatory (otherwise, we'd have lots of | undefined casts to resolve, and that seemed like a lot of changes for a minor DX improvement).