Skip to content
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

Hyper-Schema examples: wrong, confusing, or changed? #97

Closed
jdesrosiers opened this issue Oct 15, 2016 · 4 comments
Closed

Hyper-Schema examples: wrong, confusing, or changed? #97

jdesrosiers opened this issue Oct 15, 2016 · 4 comments
Milestone

Comments

@jdesrosiers
Copy link
Member

This example is either wrong, confusing, or significantly changes the semantics of Hyper-Schema. All of the examples look like this, so I'm concerned.

For example, if a schema is defined:

 {
    "links": [{
        "rel": "self",
        "href": "{id}"
   }, {
        "rel": "up",
        "href": "{upId}"
    }]
}

And if a collection of instance resources were retrieved with JSON
representation:

GET /Resource/

[{
    "id": "thing",
    "upId": "parent"
}, {
    "id": "thing2",
    "upId": "parent"
}]

Wrong
This Hyper-Schema and JSON Document do not match up in a meaningful way. The links apply to the array, not the items in the list. An array has no property "id" or "upId", so neither of these links will apply.

Confusing
Maybe you intended that the Hyper-Schema was a segment of the full Hyper-Schema describing this resource and that the LDO applied to each item in the list. In that case, the example is confusing and misleading.

Changed
The other option is that you changed the semantics of how LDO's work in a way that is not well documented.

A Hyper-Schema that correctly describes the JSON Document in the example would look like this.

{
    "type": "array",
    "items": {
        "links": [{
            "rel": "self",
            "href": "{id}"
        }, {
            "rel": "up",
            "href": "{upId}"
        }]
    }
}
@handrews
Copy link
Contributor

Or just make the example have two instances, each of which fits the current schema. Instead of stuffing them in an array.

@awwright
Copy link
Member

@jdesrosiers Yeah, it looks like this needs a lot of cleanup. Unfortunately Hyper-schema didn't get nearly as much love as "core" did.

The only interpretation that makes sense is it's providing an array of instances, each can be described by the schema.

The "base" keyword has the most up-to-date example in the document, does that form sense you you?

@jdesrosiers
Copy link
Member Author

Yes, that one looks right.

@awwright awwright added the bug label Oct 16, 2016
@awwright awwright added this to the draft-6 milestone Oct 16, 2016
handrews added a commit to handrews/json-schema-spec that referenced this issue Nov 8, 2016
This addresses issue json-schema-org#97, where it was noted that "The only
interpretation that makes sense is it's providing an array
of instances, each can be described by the schema."

This makes the schema an array schema, and replaces the "self"
link with the more correct (or at least less confusing in this
context) "item" link.

Also fix a "the the" typo in the security considerations section,
and make "hyper-schema" consistent.
handrews added a commit to handrews/json-schema-spec that referenced this issue Nov 16, 2016
This addresses issue json-schema-org#97, where it was noted that "The only
interpretation that makes sense is it's providing an array
of instances, each can be described by the schema."

This makes the schema an array schema, and replaces the "self"
link with the more correct (or at least less confusing in this
context) "item" link.

Also fix a "the the" typo in the security considerations section,
and make "hyper-schema" consistent.
@Relequestual
Copy link
Member

If you think the PR doesn't "fix" this issue, please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants