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

format: add uritemplate and jsonpointer #109

Closed
handrews opened this issue Oct 25, 2016 · 11 comments
Closed

format: add uritemplate and jsonpointer #109

handrews opened this issue Oct 25, 2016 · 11 comments

Comments

@handrews
Copy link
Contributor

We currently have uri and uriref for indicating an expectation of RFC 3986 conformance. While I don't think we should have formats for all RFC-defined things, since hyper-schema itself relies on URI Templates (RFC 6570) and JSON Pointer (RFC 6901), it seems reasonable to include them. It would make our meta-schema more clear as well.

@handrews
Copy link
Contributor Author

handrews commented Nov 5, 2016

@Relequestual @awwright @epoberezkin any thoughts? This should be a pretty straightforward yes or no, I think. Just a question of "do we want enough defined formats to be able to identify the formats on which JSON Schema itself depends?"

@erosb
Copy link

erosb commented Nov 6, 2016

+1 for jsonpointer , I'm neutral about uritemplate .

@epoberezkin
Copy link
Member

@erosb same here

@handrews
Copy link
Contributor Author

handrews commented Nov 7, 2016

@epoberezkin @erosb why less interested in uritemplate? It is a distinct format from uri and urireference and one on which we are entirely dependent for hyper schema (currently in two different keywords, href and base). Being able to express our own usage seems beneficial, particularly given the optional nature of format.

@Relequestual
Copy link
Member

@handrews Could you give examples of both? I'm not familiar with either, and therefore how this would look, which makes it difficult to know if I'm for or against.

@handrews
Copy link
Contributor Author

handrews commented Nov 8, 2016

[edit: haven't had caffeine yet, was using $ref wrong, took it out]
@Relequestual uritemplate is what we use for href and base. So in the meta-schema:

{
    "type": "object",
    "properties": {
        ...,
        "href": {
            "type": "string",
            "format": "uritemplate"
        },
        "base": {
            "type": "string",
            "format": "uritemplate"
        },
        ...
    }
}

@handrews
Copy link
Contributor Author

handrews commented Nov 8, 2016

@Relequestual currently we don't have anything where we only use JSON Pointer, but JSON Pointer is the fragment syntax we use in $ref. Some proposals use JSON Pointers directly instead of as part of URIs.

@handrews
Copy link
Contributor Author

handrews commented Nov 9, 2016

Here is a better use of JSON Pointer. This is a (probably not quite right) schema for the JSON Patch media type:

{
    "type": "array",
    "items": {
        "type": "object",
        "required": ["op", "path"],
        "properties": {
            "path": {
                "type": "string",
                "format": "jsonpointer"
            }
        },
        "oneOf": [
            {"properties": {"op": {"const": "remove"}}},
            {
                "required": ["value"],
                "properties": {
                    "op": {"enum": ["test", "add", "replace"]},
                    "value": {}
                }
            },
            {
                "required": ["from"],
                "properties": {
                    "op": {"enum": ["move", "copy"]},
                    "from": {"type": "string", "format": "jsonpointer"}
                }
            }
        ]
    }
}

@erosb
Copy link

erosb commented Nov 10, 2016

Created a PR for an other way of defining json pointers: #141

@Relequestual
Copy link
Member

OK, I feel I understand now. I'm for this! =]

handrews added a commit to handrews/json-schema-spec that referenced this issue Nov 20, 2016
Addresses issue json-schema-org#109 by adding "uritemplate" and "jsonpointer",
as defined by their RFCs, both of which already play roles
within JSON (Hyper-)Schema.

We use "uritemplate" in hyper-schema, but until the preprocessing
step is removed we technically can't put the format in the
meta-hyperschema.  This is being addressed elsewhere.

While we do not need "jsonpointer" for our meta-schema, it is
used for schema+json URI fragments, and in other JSON-based
media types such as JSON Patch.
@handrews
Copy link
Contributor Author

Resolved by PR #150.

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

4 participants