private static void extendTypeDeclarationToIncludeNull(ObjectNode node, SchemaGeneratorConfig config) {
        JsonNode fixedJsonSchemaType = node.get(config.getKeyword(SchemaKeyword.TAG_TYPE));
        final String nullTypeName = config.getKeyword(SchemaKeyword.TAG_TYPE_NULL);
        if (fixedJsonSchemaType instanceof ArrayNode) {
            // there are already multiple "type" values
            ArrayNode arrayOfTypes = (ArrayNode) fixedJsonSchemaType;
            // one of the existing "type" values could be null
            for (JsonNode arrayEntry : arrayOfTypes) {
                if (nullTypeName.equals(arrayEntry.textValue())) {
                    return;
                }
            }
            // null "type" was not mentioned before, to be safe we need to replace the old array and add the null entry
            node.putArray(config.getKeyword(SchemaKeyword.TAG_TYPE))
                    .addAll(arrayOfTypes)
                    .add(nullTypeName);
        } else if (fixedJsonSchemaType instanceof TextNode && !nullTypeName.equals(fixedJsonSchemaType.textValue())) {
            // add null as second "type" option
            node.putArray(config.getKeyword(SchemaKeyword.TAG_TYPE))
                    .add(fixedJsonSchemaType)
                    .add(nullTypeName);
        }
        // if no "type" is specified, null is allowed already
    }
Preparation Step: combine the collected attributes and the javaType's definition in the given targetNode.

@param <M> type of target scope, i.e. either a field or method
@param targetNode node in the JSON schema that should represent the associated javaType and include the separately collected attributes
@param memberDetails details for field/method to populate schema for
@param collectedMemberAttributes separately collected attribute for the field/method in their respective declaring type
@see #populateFieldSchema(FieldScope)
jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaGenerationContextImpl.java