fusi
fusi

Reputation: 330

How should a schema link be provided to the client for a hypermedia/restful json array endpoint

i have a hypermedia/restful service that exposes collections as (page-able) endpoints. these are serialized as json arrays.

i have a(n automatically generated) json schema for each endpoint and wish to communicate the location of these schemas to the client, but because the endpoints are json arrays, i cannot include a '$schema' property that contains a link to the corresponding schema.

there are a few options i can think of:

  1. wrap the array in a json object that contains the json array alongside the schema link (and any other properties specific to the collection)

  2. provide the schema link as a custom http header parameter

  3. assume the client just 'knows' how to get the schema for an endpoint, without needing to be explicitly told

  4. provide to the client the general format of the schema url at the root level which the client then remembers and uses to generate all the schema links itself

what is the best way to provide json schema links to the client?

Upvotes: 0

Views: 447

Answers (1)

fusi
fusi

Reputation: 330

the json schema core spec recommends the use of the "Content-Type" or "Link" headers, so i'm going to go with that for now.

Upvotes: 3

Related Questions