Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Copy over draft-06 meta-schemas #82

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

handrews
Copy link
Contributor

@handrews handrews commented Mar 2, 2017

as decided in issue json-schema-org/json-schema-spec#165.

Also add a README to explain why there's nothing in a Draft-05
directory, because people keep asking about that.

Copy link
Member

@Relequestual Relequestual left a comment

Choose a reason for hiding this comment

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

I realise I should actually query this on the schema repo, but as it's here, and in one PR... Plus it's probably just my lack of understanding and nothing actually wrong with it.

"links": [
{
"rel": "self",
"href": "{+id}"
Copy link
Member

Choose a reason for hiding this comment

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

Huh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a URI template: https://tools.ietf.org/html/rfc6570#section-3.2.3 and this link says that the meta-schema document itself lives at the URI of its own "$id", which (except for having left out the "$") is correct.

But now it should be "{+$id}" except that "$" is excluded from template variable expressions and reserved for pre-processors, so I guess we have to go back to saying that we have a preprocessor that just allows "$"? Ugh. Not enough caffeine for this.

I'll have to submit a PR on the other repo when I can figure out how to handle this, and after that's approved update the PR here.

Copy link
Member

Choose a reason for hiding this comment

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

OK. Have you tracked this issue on the spec repo? (I'm half asleep here =[ )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,47 @@
{
"$schema": "http://json-schema.org/draft-06/hyper-schema#",
"$id": "http://json-schema.org/draft-06/links#",
Copy link
Member

Choose a reason for hiding this comment

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

Why is the $schema and $id here set as they are?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the links meta-schema is itself a hyperschema (and its self link also needs to be changed from "{+id}" to "{+$id}" or however we end up dealing with that). And the links schema has its own id, of course.

Copy link
Member

Choose a reason for hiding this comment

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

Oh right. Yeah, with you on that now. Duh.

},
"schema": {
"description": "Schema describing the data to submit along with the request",
"allOf": [ { "$ref": "hyper-schema#" } ]
Copy link
Member

Choose a reason for hiding this comment

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

Should this be schema# or hyper-schema#? I'm not sure I really understand...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hyper-schema. Requests, responses, and representations in general are hypermedia documents. Why wouldn't they be?

Copy link
Member

Choose a reason for hiding this comment

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

To my mind, if schema describes the data being submitted with the request, it is the schema for the json, which would be schema#. Why would I include LDO information in my request payload? Or am I missing something really important to understanding this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two reasons:

  1. HATEOAS. The server may want to examine a resource related to the request representation. In which case the server needs to understand how to build links from the request.
  2. Convenience. For a POST that is creating via a collection, I want to "$ref" the same representation everywhere (POST request to create, and the regular representation which is used as both PUT request and GET response).

But the primary answer is HATEOAS.

Copy link
Member

Choose a reason for hiding this comment

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

Reads up on HATEOAS. OK then. Consider me convinced. I think I've read up on HATEOAS before and not understood or just forgotten. Welcome refresh.

},
"targetSchema": {
"description": "JSON Schema describing the link target",
"allOf": [ { "$ref": "hyper-schema#" } ]
Copy link
Member

Choose a reason for hiding this comment

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

Same question as below comment.

as decided in issue json-schema-org/json-schema-spec#165.

Also add a README to explain why there's nothing in a Draft-05
directory, because people keep asking about that.
@handrews
Copy link
Contributor Author

handrews commented Mar 7, 2017

@Relequestual I've copied over the fix for the self link so these meta-schemas should be correct now.

@Relequestual Relequestual merged commit 782ae41 into json-schema-org:master Mar 7, 2017
@handrews handrews deleted the meta6 branch March 8, 2017 18:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants