@Override
    public ObjectNode generateSchema() {
        SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_7, OptionPreset.PLAIN_JSON);
        configBuilder.with(new Swagger2Module());
        // add "$schema" property in Example.class' schema
        configBuilder.forTypesInGeneral().withTypeAttributeOverride((schema, scope, context) -> {
            if (scope.getType().getErasedType() == Example.class) {
                ((ObjectNode) schema.putIfAbsent(context.getKeyword(SchemaKeyword.TAG_PROPERTIES), schema.objectNode()))
                        .set(context.getKeyword(SchemaKeyword.TAG_SCHEMA),
                                context.createStandardDefinition(context.getTypeContext().resolve(String.class), null));
            }
        });
        // add external "$ref", if one is referenced by @Schema(ref = "...")
        configBuilder.forTypesInGeneral().withCustomDefinitionProvider(new SchemaRefDefinitionProvider());
        SchemaGeneratorConfig config = configBuilder.build();
        SchemaGenerator generator = new SchemaGenerator(config);
        return generator.generateSchema(Example.class);
    }
Example created in response to <a href="https://github.com/victools/jsonschema-generator/issues/319">#319</a>.
<br/>
Based on Swagger2 {@code @Schema} annotations, allowing to reference "external" files.
jsonschema-examples/src/main/java/com/github/victools/jsonschema/examples/ExternalRefAnnotationExample.java