-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make links optional #150
Comments
Somewhat related to #121. I think it's pretty nice that Saule theoretically (after #121 is in) allows you to implement this attribute yourself, but I agree it could be a bit more ergonomic. I imagine you want to disable links for a resource, not an endpoint. That implies the configuration should be in |
I'm not certain it's always for |
I'm curious about your use-case for per-relationship link behavior. In any case, I would like for the configuration to occur on the ApiResource. Either on the resource itself, or when the relationship is defined. Examples: // On relationship:
class PersonResource : ApiResource
{
public PersonResource() {
BelongsTo<CompanyResource>(nameof(Person.Job), "/job", LinkTypes.None);
}
}
// On resource itself:
class PersonResource : ApiResource
{
public PersonResource() {
WithLinks(LinkTypes.None);
}
} The names of the methods/enum values are not really that important (they can change). The enum could look something like this: [Flags]
enum LinkTypes
{
None = 0,
Self = 1,
Related = 2,
RelatedCanonical = 4,
All = ~None
} It would be respected by the This allows for easy configuration when the needs are simple, but it also allows custom |
In my initial case where I thought about this it's about the "self" link for a In any case I like your proposed API, will try to implement. :) |
According to the specification links are optional, see:
I've encountered situations where I would like them not included. Saule autogenerates links and has AFAIK no option to disable them all or selectively. Would it make sense to introduce such a feature?
I have tried overriding as described by https://github.com/joukevandermaas/saule/wiki/Generating-links but even if returning null there will be an empty links objekt. Also, that way seem a bit overkill and I'm thinking an attribute could perhaps be created for this purpose instead.
The text was updated successfully, but these errors were encountered: