private boolean addSubtypeReferencesInDefinition(ResolvedType targetType, ObjectNode definition) {
        List<ResolvedType> subtypes = this.generatorConfig.resolveSubtypes(targetType, this);
        if (subtypes.isEmpty()) {
            this.generateObjectDefinition(targetType, definition);
            return false;
        }
        // always wrap subtype definitions, in order to avoid pointing at the same definition node as the super type
        SchemaKeyword arrayNodeName = subtypes.size() == 1 ? SchemaKeyword.TAG_ALLOF : SchemaKeyword.TAG_ANYOF;
        ArrayNode subtypeDefinitionArrayNode = definition.withArray(this.getKeyword(arrayNodeName));
        subtypes.stream()
                .map(this::createDefinitionReference)
                .forEach(subtypeDefinitionArrayNode::add);
        return true;
    }
Check for any defined subtypes of the targeted java type to produce a definition for. If there are any configured subtypes, reference those
from within the definition being generated.

@param targetType (possibly generic) type to add
@param definition node in the JSON schema to which all collected attributes should be added
@return whether any subtypes were found for which references were added to the given definition
jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaGenerationContextImpl.java