@Override
    public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, SchemaGenerationContext context) {
        Class<?> erasedType = javaType.getErasedType();
        if (this.mainType == null) {
            this.mainType = erasedType;
        }
        if (this.mainType == erasedType) {
            return null;
        }
        return Optional.ofNullable(erasedType.getAnnotation(Schema.class))
                .map(Schema::ref)
                .filter(ref -> !ref.isEmpty())
                .map(ref -> context.getGeneratorConfig().createObjectNode().put(context.getKeyword(SchemaKeyword.TAG_REF), ref))
                .map(schema -> new CustomDefinition(schema, CustomDefinition.INLINE_DEFINITION, CustomDefinition.INCLUDING_ATTRIBUTES))
                .orElse(null);
    }
Reference to the targeted type, for which a schema is being generated, that should not be replaced by a "ref".
jsonschema-module-swagger-2/src/main/java/com/github/victools/jsonschema/module/swagger2/ExternalRefCustomDefinitionProvider.java