Skip to content

application/schema-instance+jsonย #351

Closed
@handrews

Description

@handrews

Using application/json as the instance data type imposes several limitations on JSON [Hyper-]Schema. While it is essential that application/schema+json works with plain application/json instances, defining an optional instance media type to enable additional features would make several things much easier. Specifically:

  • Using URI fragments with instances (application/json does not define any fragment resolution semantics), which would help with "anchor" (Hyper-schema: Link subject/anchorย #140).
  • Using media type parameters to connect instances to schemas and conduct content negotiation based on the schema, e.g. choosing one of several versions of a given schema.

We have at times discussed proposing registering a media type relation for application/json as part of this project, and I'm sure the idea of JSON Pointer fragments for application/json have been raised several times. But given the popularity of JSON, these things would probably have to clear a high bar, and would no doubt take quite a bit of time.

Defining an optional application/instance+json would let us manage these proposals within our own process. If they seem likely to be accepted for application/json that could still be done. There is also some precedent for this approach: JSON-LD defines application/ld+json but also provides mechanisms to interpret application/json or other +json media types as JSON-LD via a link header. We already do more or less the same thing, but as noted in #222 there are concerns with our existing approach.

Finally, my plan to get around these various issues was to define a custom vendor media type for my API. I would rather not do that if possible. And even if I have another reason to use a custom +json media type, having application/schema-instance+json [EDIT: thanks to @Relequestual for suggesting schema-instance instead of just instance) would allow me to reference it as the basis for the media type, and then only need to define additional / varying semantics. This would further encourage consistency in design and implementation, particularly for hypermedia.

Tagging @dret, @dlax, @awwright

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions