@Override
    public ObjectNode generateSchema() {
        JacksonModule jacksonModule = new JacksonModule(JacksonOption.ALWAYS_REF_SUBTYPES, JacksonOption.INLINE_TRANSFORMED_SUBTYPES);
        SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON)
                .with(jacksonModule)
                .with(Option.DEFINITIONS_FOR_ALL_OBJECTS, Option.DEFINITIONS_FOR_MEMBER_SUPERTYPES, Option.DEFINITION_FOR_MAIN_SCHEMA);
        SchemaGeneratorConfig config = configBuilder.build();
        SchemaGenerator generator = new SchemaGenerator(config);
        return generator.generateSchema(BaseType.class);
    }
Example created in response to <a href="https://github.com/victools/jsonschema-generator/discussions/337">#337</a>.
<br/>
Utilising Jackson subtype resolution in combination with various options to steer what is included in the "$defs".
jsonschema-examples/src/main/java/com/github/victools/jsonschema/examples/JacksonSubtypeDefinitionExample.java