Skip to content

Is there a way to limit the size/nested of additionalProperties Map? #171

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

You must be logged in to vote

HI @KalCramer,

What the Option.MAP_VALUES_AS_ADDITIONAL_PROPERTIES does is this:

configBuilder.forTypesInGeneral()
        .withAdditionalPropertiesResolver(scope -> {
            if (scope.getType().isInstanceOf(Map.class)) {
                // within a Map<Key, Value> allow additionalProperties of the Value type
                // if no type parameters are defined, this will result in additionalProperties to be omitted (by way of returning Object.class)
                return scope.getTypeParameterFor(Map.class, 1);
            }
            return null;
        });

You'd have to handle the scenario when scope.getTypeParameterFor(Map.class, 1) returns just Object, to define an alternati…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CarstenWickner
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