-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
✨ Proposal: Provide resourceMediaType and resourceSchema when string format is a resource identifier, similar to contentMediaType and contentSchema #1557
Comments
Thanks for the proposal. It sounds like you're suggesting that we provide the media type of a secondary resource that they'd need to fetch (e.g. from another server). If that's the case,
If the schema implementation itself isn't supposed to do anything with these hints, I recommend just adding an annotation keyword. In 2020-12, you can use any keyword, and it will be ignored by the implementation; moving forward, you'll need to prefix the keyword with |
It's a little unclear from your description, but it sounds like what you're looking for is JSON Hyper-Schema. Specifically, you're looking for We're working on some friendly getting-started type documentation for JSON Hyper-Schema, but for now all we have is the specification which can be a bit dense. If you want to provide a simple example of the kind of thing you're doing, I'd be happy to show how you could express it using JSON Hyper-Schema. |
Seems I did not send my comment. :-( @jdesrosiers I try to simplify an example. I had to take this completely out of context to be able to write this in public. {
"DetailDataReferenced": "https://bla.blub/resource.whatever"
} My JSON schema would be something like: {
"type": "object",
"properties": {
"DetailDataReferenced": {
"type": "string",
"format": "uri"
}
}
} This for sure tells me that this string is an URI (well in fact even an URL in my case), but not which media/ mime type to expect from the other side, which I have to support in my software. What we would need is something like: {
"type": "object",
"properties": {
"DetailDataReferenced": {
"type": "string",
"format": "uri",
"contentType": "application/json; profile=urn://my.own.schema"
}
}
} I used Hope this helps for explanation. |
Here's the example using JSON Hyper-Schema to describe following the URI as a link. {
"type": "object",
"properties": {
"DetailDataReferenced": {
"type": "string",
"format": "uri",
"links": [
{
"rel": "https://example.com/relations/detail-data",
"href": "{+detailUrl}",
"templatePointers": {
"detailUrl": "0"
},
"targetMediaType": "application/json",
"targetSchema": { "$ref": "urn:my-namespace:my.own.schema" }
}
]
}
}
} Note that Also note that
You can express that too with JSON Hyper-Schema. Here's the spec to learn more, https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02 |
Describe the inspiration for your proposal
I have JSON schemata, which contain URIs to further data (mostly further JSON and/ or XML, sometimes ZIPed before).
It would be helpful to have a way to define in which format this data, so people know what they can and have to support when following the data.
Describe the proposal
We already have https://json-schema.org/understanding-json-schema/reference/non_json_data#contentmediatype and https://json-schema.org/understanding-json-schema/reference/non_json_data#contentschema .
If the
type
isstring
andformat
is one of https://json-schema.org/understanding-json-schema/reference/string#resource-identifiers, allow to provideresourceMediaType
andresourceSchema
following the same rules likecontentMediaType
andcontentSchema
.Describe alternatives you've considered
I first thought about using
contentMediaType
andcontentSchema
, but this is meant for the content to be thestring
, not thestring
being the reference to it.This might cause trouble with existing tooling.
Additional context
No response
The text was updated successfully, but these errors were encountered: