Skip to content

How to customize standard json schema generation based on jaxb classes to set base64 contentEncoding #451

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

You must be logged in to vote

Hi @theseeker58,

This is certainly possible. I've created an example under #452 for the required custom configuration:

configBuilder.forFields()
        .withTargetTypeOverridesResolver(this::treatByteArrayAsString)
        .withInstanceAttributeOverride(this::addContentEncodingForByteArray);
private List<ResolvedType> treatByteArrayAsString(MemberScope<?, ?> scope) {
    ResolvedType type = scope.getType();
    if (type != null && type.getErasedType().equals(byte[].class)) {
        return Collections.singletonList(scope.getContext().resolve(String.class));
    }
    return null;
}

private void addContentEncodingForByteArray(ObjectNode schema, MemberScope<?, ?> scope, SchemaGenerationCo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@theseeker58
Comment options

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