Generating com.fasterxml.jackson.module.jsonSchema.types.StringSchema with "contentEncoding": "base64" in JAVA

Viewed 29

We have a Rest API which allows clients to GET back some binary content (e.g. Image) We are using JsonSchema to help describe the API in question so I want to built out a JsonSchema representing that content.

Looking through json-schema.org's recommendation here: [https://json-schema.org/understanding-json-schema/reference/non_json_data.html?highlight=binary][1]

The relevant JsonSchema can be represented as the following StringSchema:

{
  "type": "string",
  "contentEncoding": "base64",
  "contentMediaType": "image/png"
}
  • Searching around i found a similar question with solution but it's related to C# and relevant implementation of the underlying SchemaGenerator: https://bytemeta.vip/repo/JamesNK/Newtonsoft.Json.Schema/issues/284 But inspired by that I also tried looking through the com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator but also was not able to figure out how to built the relevant schema using that either.
  • I also tried creating a com.fasterxml.jackson.module.jsonSchema.types.StringSchema directly but was also not able to add either "contentEncoding" or "contentMediaType" keywords to the generated StringSchema.

So was wondering if anyone else happened to have any pointers on what can be done in this situation in order to generate the JsonSchema we desire?

0 Answers
Related