Skip to content

"contentSchema" for embedded string data #669

@handrews

Description

@handrews

JSON Schemas can be applied to any data that maps reasonably well into the JSON data model. We take advantage of this in JSON Hyper-Schema to apply JSON Schema to media types such as multipart/alternative and application/x-www-form-urlencoded.

contentMediaType and contentEncoding let us embed other media types into JSON strings. An example where this would be likely is with JSON Web Tokens, which have a media type of application/jwt.

The contents of a JWT are, as one might expect, JSON, but encoded in such a way that a +json media type would be inaccurate.

The contentSchema keyword would take a schema, which is applied to the contents of the string as interpreted according to contentMediaType and contentEncoding. This would be a new type of applicator, applying a schema to string contents.

There is an obvious implementation challenge, which is that implementations are not required to implement contentMediaType and contentEncoding as assertions, and may simply collect them as annotations for another application to use. A similar restriction would exist for contentSchema.

We may wish to suggest that a small number of media types with obvious roles in a JSON ecosystem, such as application/jwt, SHOULD be supported, but support for arbitrary media types and encodings obviously remains impossible.

This feature would be very useful in Hyper-Schema for JWTs and also for the contents of Cookie and Set-Cookie.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions