json-schema-org / json-hyperschema-spec

A *future* location for the JSON Hyper-Schema I-D sources.
14 stars 4 forks source link

Lack of LDO schemas use-cases or term 'target' is puzzling #14

Open askirmas opened 3 years ago

askirmas commented 3 years ago

There are hrefSchema, targetSchema, submissionSchema and own/this {"$ref": "#"} //in draft-07 notation

href is rather clear - more-like HTTP specific channel. While 'target' mostly describes output/return - Event.target, HTMLElement.target, :target vs Proxy.target.

"targetSchema" is used for requests and/or responses for several HTTP methods.

With hyper-media#HTTP, hyper-media#examples, from draft-04 to draft-07 I tried to produce all desired type notation but got lost.

  1. GET () => this - for "rel": "next" and similar target is not specified
  2. GET () => target
  3. PUT (this) => void
  4. PUT (this) => target
  5. PATCH (target) => void
  6. PATCH (target) => this
  7. POST (this) => void
  8. POST (submission) => target
  9. POST (submission) => this
  10. DELETE (this | target) => this | void

What points are wrong and what have I lost?

BTW Why links are array? I expected same as $defs - 'keyed' schema collection

jdesrosiers commented 3 years ago

It's great to hear from someone who's interested in JSON Hyper-Schema!

The "target" is the destination resource of the link. If you have a link with "href: "/person/1", the targetSchema is a schema that describes the resource at /person/1. If you GET /person/1, you can expect the response to conform to the targetSchema. If you PUT /person/1, you should send JSON that conforms to targetSchema in the request. Keep in mind that targetSchema is always just a hint. You never have a guarantee what the response is going to be with an HTTP request.

I'm not following what you're trying to do with the type notations, but hopefully the above explanation helps clear some things up. Feel free to ask some follow up questions. We also have a Slack community you can join that's usually a better place than Github issues to ask these kinds of questions. You can find the invite on the website.

Why links are array? I expected same as $defs - 'keyed' schema collection

It's possible to have two links with the same rel. The simplest way to support that is for links to be an array of LDOs.

Relequestual commented 3 years ago

As an aside, we are going to put hyper schema on ice till further notice, so if you're looking for something you can use after some changes, this isn't going to be it. We are also not going to be spending any time reviewing or triaging PRs for it.

askirmas commented 3 years ago

My point is to use HyperSchema as Contract format (even better meta-programming) for communication between client and server (and server-storage later). So maybe I'll be your in-practice researcher

jdesrosiers commented 3 years ago

@askirmas I've been working on some hyper-schema tooling. I hope you find your way over to the JSON Schema Slack. We have a channel just for hyper-schema (although there hasn't been much activity recently). It'd be great to keep in touch with you about how you use hyperschema.