mbknor / mbknor-jackson-jsonSchema

Generate JSON Schema with Polymorphism using Jackson annotations
MIT License
232 stars 75 forks source link

Sub type resolving using ClassGraph doesn't work for interfaces #134

Closed big-andy-coates closed 3 years ago

big-andy-coates commented 3 years ago

Version: 1.0.39

Given an interface type and one or more impls:

@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
private interface BaseType {}

private class SubType1 implements BaseType {
   // stuff
}

Generating a schema for either BaseType or anther type with a BaseType property does invoke ClassPath to find the subtypes, but calls getSubclasses, where as it should be calling getClassesImplementing if the base type is an interface. This means it fails to find the implementations and the created schema is incorrect.

I've worked around this locally by implementing my own resolver, but thought I'd let you know.

Great project though. Very useful. Thanks.

mbknor commented 3 years ago

I've merged your PR fixing this issue