Hello again,
> I'm still a bit confused with these fragments...
>
> If I retrieve a JSON document that returns the Link header
>
http://localhost/customer; rel="describedby", but the schema itself
> specifies an "id": "
http://localhost/customer#" I have a problem. Before I
> retrieve the schema, I'd try to find
http://localhost/customer in my schema
> cache, and if I don't find it, I'd retrieve the schema from the specified
> location and cache it using its id value as key (including the appended
> fragment separator). IOW, the next time I receive said Link header, I do
> another server round trip to retrieve something I already have in my cache.
>
Well, this is why in my JsonRef class, I have a .getLocator() method
which returns the URI _without_ the fragment part ;) This way I can
avoid "checking out" the schema twice.
Again, because this is a JSON Reference and the canonical form of a
JSON Reference is a base URI followed by a JSON Pointer fragment.
>
> I also question that fragments are followed by a JSON Pointer notion. Lets
> add and "id" value to definitions/address with value "#address" to my
> original sample:
>
[...]
Yes, this is unfortunately the case that JSON Schema has to "extend"
upon JSON Reference to allow arbitrary fragments. I wished it removed
but I was alone in that...
> {
> "$schema": "
http://json-schema.org/draft-04/schema#",
> "id": "
http://localhost/customer
> #",
>
> "description": "Customer",
> "type": "object",
> "properties": {
> "name": { "type": "string" },
> "address": { "$ref": "#/definitions/address" }
>
> },
> "required": ["name", "addresses"],
> "definitions": {
> "address": {
> "id" : "#address",
> "type" : "object",
> "properties": {
> "street": { "type": "string" },
> "number": { "type": "string" },
> "suburb": { "type": "string" },
> "city": { "type": "string" },
> "postcode": { "type": "integer" }
> }
> }
> }
> }
>
> Could I not now reference the definition of address from this schema in
> other schemas with
http://localhost/customer#address?
>
Spot on... The only answer I can give here is "I don't know". My
implementation _does_ reference this correctly, no idea for others.
Using JSON Pointers as fragment parts, however, removes the ambiguity!
> If I understand the specs correctly, #definitions/address is a JSON pointer
> and a valid reference I could use, but so is #address which is not a JSON
> pointer but an in-lined schema id. If my interpretation is correct, than
> this could lead to ambiguities unless the resolution is always in-lined
> before JSON pointer resolution.
>
> Did I miss this part in the specs?
>
No you didn't. This is indeed a source of potential problems, which I
have fought to be solved but never got to solve.
Yes, I still want non JSON Pointer fragments removed from the spec.
And yes, I am the only one who wants that :(