Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add most of a collection example. #448

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

Merged
handrews merged 1 commit into json-schema-org:master from handrews:collection
Oct 20, 2017

Conversation

@handrews
Copy link
Contributor

@handrews handrews commented Oct 19, 2017

There are some things that are not addressed here, and most
importantly this highlights the problems that I wrote about
in issue #421. Hopefully they are more clear when laid out
like this and noted in CREFs.

I feel like it is a prerequisite of a hypermedia format that
claims to be feature-complete to be able to recognize
self-describing collections and make use of them without having
specific knowledge of the data type of their contents.

<t>
This schema describes a collection where each item representation is
identical to the individual resource item representation, and there
is enough metadata included in the collection representtion to
Copy link
Collaborator

@philsturgeon philsturgeon Oct 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

representtion

Copy link
Contributor Author

@handrews handrews Oct 20, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks- fixed with a squashed commit that only changed this one word.

Copy link
Collaborator

This is a great direction. A little typo but great content. Seeing as a lot of what JSON Schema is going to be used for is CRUDy REST(ish) APIs, this example is really going to drive the point home to people doing that.

There are some things that are not addressed here, and most
importantly this highlights the problems that I wrote about
in issue #421. Hopefully they are more clear when laid out
like this and noted in CREFs.
I feel like it is a prerequisite of a hypermedia format that
claims to be feature-complete to be able to recognize
self-describing collections and make use of them without having
specific knowledge of the data type of their contents.
@handrews handrews changed the base branch from examples to master October 20, 2017 19:09
Copy link
Contributor Author

Given the significance of this example and the one enthusiastic approval, I'm going to go ahead and merge this to get it into the "final review" announcement. Obviously further comment is very much desired and welcome, and merging this does not set it in stone at all.

@handrews handrews merged commit 7546fb0 into json-schema-org:master Oct 20, 2017
@handrews handrews deleted the collection branch October 20, 2017 19:10
Copy link
Member

dlax commented Nov 1, 2017

I agree with @philsturgeon that this example demonstrates the power of JSON Hyper Schema, however, it is very complicated and thus I suspect many people will get lost quite quickly. (I find myself lost, to be honest.)

One thing that'd help would be to leave the pagination part aside and only focus on collection+item links (plus POST semantics). Hence, the collection schema could be a simple array.

A more complete example with pagination could be in the form of a tutorial on the website.

Copy link
Contributor Author

handrews commented Nov 1, 2017
edited
Loading

@dlax I don't find an array example to be very compelling. For me, that's not a real-world example. Collections that are filterable or paginated/scrolling are unmanageable under hyper-schema without meta-data, and showing a "collection" that can't be filtered or paginated is not realistic.

While I don't want to make the standard a tutorial, this is THE design pattern of REST and experience tells me that few people will get it right on the first try with Hyper-Schema. I certainly did not. It uses nearly all of the LDO features in ways that are not always obvious but are crucially important.

I would definitely be interested in suggestions on how to build up to it in more steps, organize it better, or explain it better. But I think a fully functional collection (with at least one of pagination or filtering, and pagination is easier) is the most important example to have.

This gets back to the difference in how you and I see examples. I dislike small examples all over the place that break up the flow of text. What I really want to see is how you use everything together for something of real-world complexity. That is what is interesting, because it is not obvious how to do this from just reading all of the features.

@philsturgeon do you have any thoughts on this?

I would love to find a way to reach this level of example even if we break it up into more subsections.

Copy link
Contributor Author

handrews commented Nov 1, 2017

@dlax also if you want to get into an involved discussion on how to improve this example, maybe file an issue for it? I just realized this is a closed PR.

Copy link
Collaborator

@handrews in my opinion @dlax makes a great point. The confusion between "items" in the server response and "items" as a JSON Schema keyword is really going to throw a lot of people, but as you say documenting a bare array is going to confuse people further.

People do not generally return bare arrays for collections due to whispers of "its not secure", which is mostly a tiny vector in outdated browsers that only exists if your API supports sessions, which... ugh what.

So, we have a confusing example, with a confusion option suggested. How do we resolve this?

Renaming "items" might be a good start?

Copy link
Contributor Author

handrews commented Nov 1, 2017

@philsturgeon we can definitely rename items. Sometimes I call it "elements", depending on whether I think the symmetry or lack of symmetry is more confusing. ̄_(ツ)_/ ̄

I'm also open to other names. "contents"? "theActualStuff"? :-P

Should this be broken into two examples? I could do it without pagination, and then add pagination.

Copy link
Collaborator

Right on!

Some folks call it data which is pretty darn vague, or... <foo>s

Copy link
Contributor Author

handrews commented Nov 1, 2017

I think I'll avoid "data", "results", or anything else that might look like a generic response envelope rather than something specific (so "contents" is probably out as well).

I go back and forth with "foos". If there's a well-defined domain vocabulary with rules for plurals, that works well. If not, it's better to have something standard-ish ("items" or "elements"). Of course I also don't want the examples to be a rathole of stylistic debates on API design, either.

Copy link
Contributor Author

handrews commented Nov 2, 2017

@dlax @philsturgeon posted PR #464 to attempt to address this.

Copy link
Member

dlax commented Nov 2, 2017

@handrews

PR #464 to attempt to address this.

That's a good step forward.

@dlax also if you want to get into an involved discussion on how to improve this example, maybe file an issue for it? I just realized this is a closed PR.

Opened #465 to discuss about pagination more specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@awwright awwright Awaiting requested review from awwright

@Relequestual Relequestual Awaiting requested review from Relequestual

@dlax dlax Awaiting requested review from dlax

1 more reviewer

@philsturgeon philsturgeon philsturgeon approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /