json-schema-org / json-schema-spec

The JSON Schema specification
http://json-schema.org/
Other
3.76k stars 265 forks source link

What does it mean to implement Hyper-Schema? #413

Closed handrews closed 7 years ago

handrews commented 7 years ago

I think that we should also have an introductory section explaining what an implementation of Hyper-Schema would look like, and what it is called. For JSON Schema validation, it's pretty clear that the thing one would implement is a validator. But people do implement other things (code/ui/doc generators) which is where many feature requests arise that do not fit into validation.

For Hyper-Schema, we use terms like "user agent" and "client", but it's pretty vague as to what those mean, exactly, and where Hyper-Schema fits in. While "user agent" does have a somewhat formal meaning, "client" could mean the user agent, or could mean a client application.

This is particularly important when considering HATEOAS, and discussing what the "application state" is and how it is maintained. Hyper-Schema should not become a treatise on HATEOAS, but a few pointers defining terminology and explaining how the concepts align would be very helpful.

The "user agent" here is a generic client. Like a web browser does for interactive hypermedia, the JSON Hyper-Schema driven user agent understands media types and protocols, but not the applications that use those media types and protocols.

The "client application" (unless someone has a better term) sits on top of the "user agent" and is aware of application-specific concepts. But it does not necessarily need to directly understand media types and protocols any more than a human using a browser does. It can, of course (as JavaScript applications running within the browser often do). But it should be possible to program an application on top of a Hyper-Schema aware user agent without worrying about how application/[*+]json, application/schema+json, HTTP, HTTPS, mailto: URIs, etc. etc. get used behind the scenes.

handrews commented 7 years ago

This should also help us figure out what a Hyper-Schema conformance test suite would look like.

handrews commented 7 years ago

Thoughts on implementation components and test cases (some of these are optional as they are MAY requirements, like recognizing collections via "item" links, or protocol-dependent, like HTTP's "allow"):

handrews commented 7 years ago

Another component that needs implementing and testing is determining whether a given link applies to a given (sub)instance. The interesting things to test are the ones in the "Integration with validation" section (or whatever I called it). Ensuring that while schemas deep in allOf and validating anyOf/oneOf/then/else branches contribute links, schemas in no-validating branches and under not do not.

handrews commented 7 years ago

Largely addressed in #427

handrews commented 7 years ago

Merged #427. Further work is needed in the test repository, but we'll track that separately.