Is your feature request related to a problem? *
From my current point of view, this library does not allow to add other links, besides pagination, then self or related to the document or resource. The JSON:API specification does not describe a restriction to this.
As an example, it is not possible to describe an API entry point that only contains links and might also contain document metadata.
Describe the solution you'd like*
I could imagine, that the properties document and resource in the linkers option will allow a map containing the link names, self as an example, as the key, and the Linker as the value.
Example:
return new Serializer('', {
version: null,
linkers: {
document: {
self: new Linker(() => 'https://example.com/api'),
resource: new Linker() => 'https://example.com/api/resources').
},
},
metaizers: {
document: new Metaizer(() => ({
foo: 'bar',
})),
},
}).serialize(undefined);
Another solution might be that the Linker could return a map of links:
Example:
return new Serializer('', {
version: null,
linkers: {
document: new Linker(() => ({
self: 'https://example.com/api',
resource: 'https://example.com/api/resources'
})),
},
metaizers: {
document: new Metaizer(() => ({
foo: 'bar',
})),
},
}).serialize(undefined);
Describe alternatives you've considered*
Serializing resources with other links by hand or amending the serialization result.
Is your feature request related to a problem? *
From my current point of view, this library does not allow to add other links, besides pagination, then self or related to the document or resource. The JSON:API specification does not describe a restriction to this.
As an example, it is not possible to describe an API entry point that only contains links and might also contain document metadata.
Describe the solution you'd like*
I could imagine, that the properties
documentandresourcein thelinkersoption will allow a map containing the link names,selfas an example, as the key, and theLinkeras the value.Example:
Another solution might be that the
Linkercould return a map of links:Example:
Describe alternatives you've considered*
Serializing resources with other links by hand or amending the serialization result.