private void populateMemberSchemaWithReference(ObjectNode targetNode, GenericTypeDetails typeDetails,
            ObjectNode collectedMemberAttributes, CustomDefinition customDefinition) {
        // create an "allOf" wrapper for the attributes related to this particular field and its general type
        final ObjectNode referenceContainer;
        boolean ignoreCollectedAttributes = customDefinition != null && !customDefinition.shouldIncludeAttributes()
                || Util.isNullOrEmpty(collectedMemberAttributes);
        if (ignoreCollectedAttributes) {
            // no need for the allOf, can use the sub-schema instance directly as reference
            referenceContainer = targetNode;
        } else if (customDefinition == null && typeDetails.getScope().isContainerType()) {
            // same as above, but the collected attributes should be applied also for containers/arrays
            referenceContainer = targetNode;
            AttributeCollector.mergeMissingAttributes(targetNode, collectedMemberAttributes);
        } else {
            // avoid mixing potential "$ref" element with contextual attributes by introducing an "allOf" wrapper
            // this is only relevant for DRAFT_6 / DRAFT_7 and is being cleaned-up afterward for newer schema versions
            referenceContainer = this.generatorConfig.createObjectNode();
            targetNode.putArray(this.getKeyword(SchemaKeyword.TAG_ALLOF))
                    .add(referenceContainer)
                    .add(collectedMemberAttributes);
        }
        // only add reference for separate definition if it is not a fixed type that should be in-lined
        try {
            this.traverseGenericType(referenceContainer, typeDetails);
        } catch (UnsupportedOperationException ex) {
            logger.warn("Skipping type definition due to error", ex);
        }
    }
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