I see at least 2 scenarios where you might want to provide hints about more than one target schema:
1- error vs success schemas
2- async vs sync schemas
I don't see in current JSON schema a way to describe more than one schema for a given link definition.
I agree that at runtime, server can advertise which schema is associated to returned payload using profile or link header.
I am interested how we can document supported error codes (a resource may not support all HTTP codes or may want to explicit error cases client should be ready to support) and more generally, how to let a link describe many possible target schemas.
Any ideas?
Typically a server would respond synchronously to a request sending 200 along a payload.
But sometimes server may decide to defer processing of a request and reply with 202 HTTP code along a payload that would typically describe status of processing.
The client may have a query param or HTTP header to explicit async processing or the server may decide on its own (eg based on server current load). In latter case you would expect client to be aware of both potential payloads (and associated schemas), then based on content type profile parameter returned by server (or returned link header) parse response accordingly.
Makes sense?
Maybe a misinterpreted the "targetSchema" semantic. I thought it was used to hint about the expected target response associated schema. Maybe we could address my need with having target schema ref'ing a schema using a combination of anyOf attribute to explicit each possible message structure to expect on response?
For async use case, not disputing the semantic aspect of it. I just used this as another case where Content-Type header of expected HTTP response may be many different values for a given resource. I thought it would be useful to have a way to describe each possible media type structure that one may expect on a given endpoint using JSON schema description language.
To get back on Ning original question, most open REST APIs do document the error codes they support. There must be a good reason for this. I like the idea of using JSON schema to auto document my APIs, and error codes would need to be part of the schema for this reason.
--
You received this message because you are subscribed to a topic in the Google Groups "JSON Schema" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/json-schema/B-rcbriwNdc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to json-schema...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.