Skip to content

How to specify contentEncoding and contentMediaType keywords of JSON Schema #412

Answered by sinclairzx81
jmartinacu asked this question in Q&A
Discussion options

You must be logged in to vote

@jmartinacu Hi,

For images, you will most likely want to use contentMediaType: 'image/png' (or other mime type) and contentEncoding: 'base64'.

These are options available on Type.String()

const T = Type.String({ contentMediaType: 'image/png', contentEncoding: 'base64' })

Additional information on these options can be found at the link below

https://json-schema.org/understanding-json-schema/reference/non_json_data.html#id1

As noted in this documentation, validators are not likely to validate for specific media types encoded in JSON, so you may need to manually validate the image data yourself. Additionally, you may also need to handle encoding and decoding the images to and from base64 (so…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sinclairzx81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants