protected CustomPropertyDefinition provideCustomSchemaDefinition(MemberScope<?, ?> scope, SchemaGenerationContext context) {
        Optional<String> externalReference = this.getSchemaAnnotationValue(scope, Schema::ref, ref -> !ref.isEmpty());
        if (!externalReference.isPresent()) {
            return null;
        }
        // in Draft 6 and Draft 7, no other keywords are allowed besides a "$ref"
        CustomDefinition.AttributeInclusion attributeInclusion;
        switch (context.getGeneratorConfig().getSchemaVersion()) {
        case DRAFT_6:
        // fall-through (same as Draft 7)
        case DRAFT_7:
            attributeInclusion = CustomDefinition.AttributeInclusion.NO;
            break;
        default:
            attributeInclusion = CustomDefinition.AttributeInclusion.YES;
        }
        ObjectNode reference = context.getGeneratorConfig().createObjectNode()
                .put(context.getKeyword(SchemaKeyword.TAG_REF), externalReference.get());
        return new CustomPropertyDefinition(reference, attributeInclusion);
    }
Implementation of the {@code CustomPropertyDefinitionProvider} to consider external references given in {@code @Schema(ref = ...)}.

@param scope field/method to determine custom definition for
@param context generation context
@return custom definition containing the looked-up external reference or null
jsonschema-module-swagger-2/src/main/java/com/github/victools/jsonschema/module/swagger2/Swagger2Module.java