@Override
    public ObjectNode generateSchema() {
        SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON);
        configBuilder.with(Option.DEFINITIONS_FOR_ALL_OBJECTS, Option.DEFINITIONS_FOR_MEMBER_SUPERTYPES);
        configBuilder.forTypesInGeneral()
                .withSubtypeResolver(new ClassGraphSubtypeResolver());
        SchemaGeneratorConfig config = configBuilder.build();
        SchemaGenerator generator = new SchemaGenerator(config);
        return generator.generateSchema(Example.class);
    }
Example created to show-case generic subtype look-up.
<br/>
Using classgraph for determining type hierarchy.
jsonschema-examples/src/main/java/com/github/victools/jsonschema/examples/SubtypeLookUpExample.java