format: binary had limitations when you needed to specify both the media type and the encoding. Specifically, this example from OAS 3.0.2:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
profileImage:
# default is application/octet-stream, need to declare an image type only!
type: string
format: binary
Note how it says that you "need to declare an image type only" because format: binary just indicates application/octet-stream (the universal media type that encompasses everything).
In OAS 3.1, the corresponding example is follows, sadly with an error- the comment about application-level encoded resources being text/plain is incorrect. I seem to have missed that when I put this example in, my apologies- it is correct elsewhere in the spec:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
profileImage:
# Content-Type for application-level encoded resource is `text/plain`
type: string
contentMediaType: image/png
contentEncoding: base64
These examples are slightly different as the OAS 3.1 shows a base64 encoding, which would have been format: byte. The exact OAS 3.1 analogue would be:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
profileImage:
contentMediaType: image/png
without a type (because binary data, while valid in a multipart form submission which is what this is from, is not part of the JSON type system).
It is slightly confusing because the Encoding Object overlaps the JSON Schema keyword functionality a bit, which is the result of OAS and JSON Schema independently trying to solve the same problem. OAS 3.1 specifies that if the Encoding Object is used, then JSON Schema's contentMediaType SHALL be ignored. But you might still see both if the JSON Schema is intended for use both inside of and outside of OpenAPI.
JSON Schema's examples, enum, and const keywords take literal values. As base64-encoded binaries are simply strings, they can be used with these keywords in the normal way.
However, unencoded binary cannot be embedded in JSON or YAML as a literal value. The JSON Schema keywords were primarily designed for the JSON data model.
However, OpenAPI's Example Object (which is outside of the schema object) allows for an external reference to other media types. There are not currently any such external reference keywords for JSON Schema, but the could be added as an extension vocabulary, meaning it is not necessary to wait for a new draft of JSON Schema or a new version of the OpenAPI Specification to do this.
examples and default are annotation keywords, and the default extension keyword behavior is to be an annotation, so there's not much you'd need to do to add them. const and enum would be a bit more challenging as JSON Schema does not expect to load other media types for validation. But enum has never supported unencoded binary data in OAS, nor did example or default in the OAS 3.0 Schema Object, so these are not new restrictions.