-
-
Notifications
You must be signed in to change notification settings - Fork 313
hyper-schema: LDOs and anyOf/allOf/oneOf/not/dependencies #157
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
This is my understanding as well. Links never replace each other, there can be multiple links with the same relationship. The best example is the "stylesheet" relationship. Links can also have multiple "self" "author" "alternate" "tag" and "type" relations, among others. |
Sounds good. I'm trying to figure out a situation in which an API client might want to follow a link with a particular relationship and not be able to decide among multiple links with that relationship, but I think I'm fabricating that problem out of nothing. Certainly for "stylesheet" and most of the others, if you have multiple, that just means you need to loop over them and look at each of them. Multiple "self" links are a bit more confusing for me, although I may just be misunderstanding some aspects of "self". I have only used "self" in a root schema. Is the "context" which is identified by self the immediate containing schema or is it the schema document? In other words, does it make sense to have a "self" link in a subschema? |
One case is if you're creating a front page of blog posts (e.g. list the 20 most recent blog posts in reverse chronological order), you have an array of JSON instances that each have their own URIs. |
Why would you use "self" instead of "item" in that case? |
I am assuming that by "array of JSON instances" you mean a single JSON document that validates against a particular schema, and the LDO with the "self" link is in the "items" (or "additionalItems") schema. |
An "items" link would be from some sort of collection of posts, with a link pointing to each blog post. The blog post itself would also have a "self" link (to itself) that gives itself a URI. |
I guess I'm having trouble understanding the distinction between a list of blog posts in a JSON document and a collection of posts, but I am fine with the use case and can read up more on my own. What about Saying that one true |
Honestly, idk. Technically, "properties" and "items" are just keywords for validation. All they do is return true or false. People have been reading in that we can recursively apply the semantics, and that's fine too. Maybe we should make that more explicit. The best advice I've got for handling metadata keywords like readOnly or description is... use common sense. I tend to think all keywords can be defined multiple times, and they all apply in that case. It'll be something we deal with once we understand better what the implementations look like. |
LOL this whole issue is because I have a code file open trying to implement this right now :-) Algorithm looks something like this (for the whole thing, keep track of hyper-schema For each JSON Pointer that resolves to a value in the instance: If the representation in-memory is changed in such a way that validation changes, such as changing which branch of a |
The most urgent part of this was addressed by PR #251 (I just forgot to reference this issue). While there are other topics here (such as exactly how to merge LDOs), I think that as we come to understand those better through implementation, we should create individual issues for them. For now, we clarified that only schemas that validate apply hyper-schema keywords to instances, and nothing under |
I think it would be a good idea to clarify the use of LDOs with the combinatoric keywords. I think this is what should happen, but I'm not sure:
An LDO may only be used with an instance if the instance is valid against the schema in which the LDO appears.
LDOs within a "not" cannot ever be used (I just can't figure out how using them would make any sense)
What happens if LDOs in "allOf" branches or in valid "anyOf" branches define links with the same "rel" values?
The text was updated successfully, but these errors were encountered: