Media - sgpinkus/json-schema GitHub Wiki

THIS WIKI IS OBSOLETE. PLEASE SEE THE NEW JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.



Description

This keyword would be meant to supersede both contentEncoding and mediaType.

Those two keywords are right now part of the hyper schema definition. The proposed keyword would still be part of the hyper schema.

media and validation

Implementations MAY, but are not required to, validate a JSON instance against this keyword. If contentEncoding is being used for validation, the instance SHOULD be considered valid if its value can be correctly decoded into binary data using the specified encoding method.

Implementations MAY add further attributes to this keyword's object value for a more refined analysis of the instance. If they do so, they SHOULD NOT expect that these attributes be handled by a peer implementation.

Possible values

The value for this keyword MUST be an object.

This object MUST have at least one member named contentEncoding. The value of contentEncoding MUST be a JSON string value, and this string value MUST be the description of a binary encoding format, as specified in RFC 2045, Sec 6.1.

This object MAY have a member named mediaType. If this member is present, its value MUST be a JSON string value, and this string value MUST be a valid type "/" subtype pair, as specified in RFC 2045, sec 5.1.

Example

{
    "media": {
        "contentEncoding": "base64",
        "mediaType": "image/png"
    }
}

Schema validation

This is the proposed schema validation entry:

{
    "type": "object",
    "properties": {
        "contentEncoding": {
            "type": "string"
        },
        "mediaType": {
            "type": "string"
        }
    },
    "required": [ "contentEncoding" ]
}

Ideally, there could also be mimeType and contentEncoding format attributes, but that is probably too far fetched

⚠️ **GitHub.com Fallback** ⚠️