title: Use JsonTypeInfo.As.EXTERNAL_PROPERTY without specifying @JsonSubTypes
body: <p>Is it possible to use <code>@JsonTypeInfo.As.EXTERNAL_PROPERTY</code> without needing to specify the subtypes using <code>@JsonSubtypes</code>?</p>
  
  <p>The use case is that I'm wanting to create common base classes, which has varying bodies that are declared in other projects.</p>
  
  <p><strong>Common base class, which contains common fields and the body</strong></p>
  
  <pre><code>public class ApiModel&lt;T extends ApiBodyModel&gt; {
  
      private String modelType;
      private String version;
      private T body;
  
  ... getters / setters
  
  }
  </code></pre>
  
  <p><strong>The abstract body model, which has further shared context within.</strong></p>
  
  <pre><code>@JsonTypeInfo(use = Id.NAME, include = As.EXTERNAL_PROPERTY, property = "modelType")
  //@JsonTypeIdResolver(InheritanceTypeIdResolver.class)
  public abstract class ApiBodyModel&lt;T extends ApiBodyModel&lt;T&gt;&gt; {
  
      @JsonProperty
      private ApiContextModel context;
  
      public T withContext(ApiContextModel context) {
          this.context = context;
          return (T) this;
      }
  
  ... getters / setters
  
  }
  </code></pre>
  
  <p>One solution which allowed me to drop the use of <code>@JsonSubTypes</code> was to use Reflection to get all subtypes of the abstract <code>ApiBodyModel</code>, detailed at <a href="https://gist.github.com/root-talis/36355f227ff5bb7a057ff7ad842d37a3" rel="nofollow noreferrer">https://gist.github.com/root-talis/36355f227ff5bb7a057ff7ad842d37a3</a>, but it still required the classname to be declared within the body, instead of one level up.</p>
  
  <p>Examples found for using <code>@JsonTypeInfo.As.EXTERNAL_PROPERTY</code> had <code>JsonSubTypes</code> declared, but I want to avoid this as the abstract class will be in a common project.</p>