baseUri (v5 proposal) - sgpinkus/json-schema GitHub Wiki
JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.
THIS WIKI IS OBSOLETE. PLEASE SEE THE NEWNOTE: This discussion, including the entire contents of this page, has been moved to https://github.com/json-schema-org/json-schema-spec/issues/46
Proposed keywords
baseUri
Purpose
For convenience, specify a base URI against which schema-defined links will be resolved. This allows shorter href
values.
Values
baseUri
must be a URI Template (resolved against current base URI, or request URI).
(v4 actually mentioned that rel="self" links could be used for this, but that's not ideal.)
Example
{
"baseUri": "/items/{id}/",
"links": [
{
"rel": "comments",
"href": "comments/"
},
{
"rel": "related",
"href": "related/"
}
]
}
Concerns
Does this propagate into children? Either:
- You have to also specify
baseUri
for every schema that defines links baseUri
applies to the data - at which point, what if multiple schemas have multiple values? Ideally, each schema would use its ownbaseUri
for its own links, but that gets complicated when it comes to child properties.