How to add nullable type when using MAP_VALUES_AS_ADDITIONAL_PROPERTIES? #400
-
Beta Was this translation helpful? Give feedback.
Answered by
CarstenWickner
Nov 9, 2023
Replies: 1 comment 1 reply
-
Hi @namgaxilem, For now, you might want to give this a try: configBuilder.forTypesInGeneral().withAdditionalPropertiesResolver((scope, context) -> {
if (scope.getType().isInstanceOf(Map.class)) {
ObjectNode schema = context.getGeneratorConfig().createObjectNode();
ArrayNode anyOf = schema.putArray(context.getKeyword(SchemaKeyword.TAG_ANYOF));
anyOf.addObject().put(context.getKeyword(SchemaKeyword.TAG_TYPE), context.getKeyword(SchemaKeyword.TAG_TYPE_NULL));
anyOf.add(context.createStandardDefinitionReference(scope.getTypeParameterFor(Map.class, 1), null));
return schema;
}
return null;
}); Need to find some more time to think about how to best handle this case in a more standardized way. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
namgaxilem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @namgaxilem,
For now, you might want to give this a try:
Need to find …