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

Allow use of $ref in LDOs #75

Closed
slurmulon opened this issue Oct 8, 2016 · 2 comments
Closed

Allow use of $ref in LDOs #75

slurmulon opened this issue Oct 8, 2016 · 2 comments

Comments

@slurmulon
Copy link

slurmulon commented Oct 8, 2016

While building out a complex platform built around JSON Hyper-Schema, we thought it would be nice if you could provide a $ref value to Link Description Objects:

{
  "rel": "create",
  "href": "/api/v1/user/{uuid}",
  "method": "POST",
  "$ref": "root.json#/user"
}

This would allow clients consuming JSON Hyper-Schema to pre-validate requests to the API, sparing (potentially) redundant API calls from being made. Requests can be considered redundant when both the client and API support JSON Hyper-Schema and the API is validating requests through the resource (described in the LDO) with the same schemas - so either way, the end result can be the same, it's just one approach allows you to circumvent the need for network traffic. In my mind, when the client has the exact same validation capabilities as the API there's no point in making requests that contain an invalid body.

Much like targetSchema, this should be an optional property.

I believe that this feature could also help promote (ever so slightly) the use of JSON Schema on both the front-end and back-end, helping people utiilize a powerful layer of common communication.

@jdesrosiers
Copy link
Member

First of all, $ref can't be used in this way. When $ref is present, all other properties in the object are to be ignored. The entire LDO would get wiped out and replaced with whatever "root.json#/user" points to. It would no longer be an LDO.

Second, what is the difference between what you are proposing and the schema keyword?

{
  "rel": "create",
  "href": "/api/v1/user/{uuid}",
  "method": "POST",
  "schema": { "$ref": "root.json#/user" }
}

@slurmulon
Copy link
Author

Ah sorry, schema had slipped my mind and my eyes for some reason - it does exactly what I'm proposing. We were talking about this in another thread, not sure why it was overlooked.

http://json-schema.org/latest/json-schema-hypermedia.html#anchor38

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

2 participants