Skip to content

How to programmatically generate JsonSchema representing binary content in Java #271

Closed Answered by CarstenWickner
lzemskov asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @lzemskov,

Some context might be helpful here. Is your API just returning binary content directly?

  • If yes, then just taking the static schema should be good enough.
  • If not, then I'm assuming you have a class, containing some property that represents the file contents, such as per this example:
public class BinarySchemaExample {

    public static void main(String[] args) throws JsonProcessingException {
        SchemaGeneratorConfigBuilder config = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON);
        config.forTypesInGeneral().withCustomDefinitionProvider(new CustomBinaryDefinitionProvider());
        SchemaGenerator generator = new SchemaGe…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lzemskov
Comment options

@CarstenWickner
Comment options

Answer selected by lzemskov
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