-
-
Notifications
You must be signed in to change notification settings - Fork 313
Allow "$ref"
for LDOs
#319
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
Comments
I have no objection to allowing
|
I'm not trying to override fields, I'm trying to compose them, which is how we use "links": [
{
"title": "All the Things",
"rel": "collection",
"allOf": [{"$ref": "#/definitions/thingQueryingLink"}]
}
],
"definitions": {
"thingQueryingLink": {
"href": "/things{?a,b,c,d}",
"hrefSchema": {
"type": "object",
"properties": {
"a": {...},
"b": {...},
"c": {...}
}
}
}
} and that works just fine. And if I want to link from some other context resource to a pre-filtered instance of the target collection, I just do the same thing with the correct different rel, and also use the allOf to pre-pin one of the filters: "links": [
{
"title": "My Related Things",
"rel": "tag:example.com,2017:fancythings",
"allOf": [
{"$ref": "#/definitions/thingQueryingLink"},
{
"hrefSchema": {
"properties": {"a": {"const": "fancy"}}
}
}
],
}
] As usual I'm coming up with this off the top of my head so if something doesn't make sense it's probably an error, just ask. Anyway, "allOf" has the effect of "apply all of these things separately". In these examples, that works fine. Overlying a const property onto the If you try to use
We have the same problem in several other situations for documentation and UI work with |
As I suspected there was something missing. Just allowing I'm thinking that using |
Yeah, looking back that's kind of a glaring omission, isn't it? I filed this really quickly when I ran across some annoying re-use issue and was like "this should be easier!" It was more a "don't forget this" than a carefully considered proposal :-P Anyway, yeah, I agree that using something other than This might end up related to the Documentation project (which I really need to launch properly- we have the repo set up). The semantics needed for links are more like those needed to customize Alternatively, the only real problem that I have here is that I want to be able to keep So that's the part I think is really worth solving. We don't necessarily have to solve that with general link re-use/merging/whatever. One option could even be: "links": [
{
"rel": "self",
"href": {
"uri": "/foo/{id}/bar{?a,b,c}",
"uriSchema": {
}
}
}
] and then allow a reference for the |
Another use case that has come up is defining an LDO without a Still not 100% sure what to do about I'd like to sort this out enough to write a PR and get feedback on something more concrete soon. |
Questions to resolve:
Any other open issues? I am leaning towards a new keyword, but it clearly has some complexities. I am also open to other suggestions on how to facilitate re-use. Nesting closely related keywords such as |
As noted above, this is actually somewhat complex. I'm booting it out to the next draft. I may experiment with some implementations in doca if I really have clear use cases, and let that help determine what behavior is worth standardizing, if any. |
Ultimately, allowing an array for URI Templates can be pretty annoying to duplicate, but unless we get real feedback that it's a problem that needs solving, I'm inclined to close this without further action. Any objections? |
It's been three (fairly active) weeks with no comments. I floated a Therefore I am closing this. |
It's fairly common links to connect multiple source resources to the same target resource. This often involves a lot of duplication in the LDO, but only the schema keywords can be re-used through
"$ref"
.This can be annoying when the link is almost entirely the same. In particular,
"href"
and"hrefSchema"
need to match, so they are best re-used in pairs, which is not currently possible.Since
"links"
is an array, having a schema consisting of just a"links"
array is one re-use option, but only if the desired effect is essentially concatenating the arrays. Tweaking an individual LDO (use case: same"href"
,"hrefSchema"
,"targetSchema"
and"rel"
, but applying a different title at each point of use) is somewhere between challenging and impossible.I propose that we allow
"$ref"
for an LDO (as elements of the"links"
array).Since keeping track of array positions is a pain, we should add a new
"linkDefinitions"
keyword, which is an object where each property value is an LDO instead of a schema.I'm fine with waiting a while to get feedback on draft-06 and see how much this comes up in practice, but it has come up even in some fairly trivial examples I've tried to write recently.
The text was updated successfully, but these errors were encountered: