title: How to configure swashbuckle correct for polymorphism
body: <p>I have a problem to get the right OpenApi definition aftr update from 5.0.0 to 5.4.1</p>
  <p>We had custom Polymorphism filter with 5.0.0 version, but they does not work correct with latest one. So I removed them and started to use GeneratePolymorphicSchemas(). It does what I need for our polymorphic models but not just for them. We have also some other abstract and concrete classes, where we don't need type discriminator. I tried different configurations but without any success. Either the generated definition is wrong or I get error on swagger UI or a server 503 error.</p>
  <p>Link to the sample project <a href="https://axsoftgbr-my.sharepoint.com/:u:/g/personal/d_axenowski_ax-soft_de/EeBQbsXDfnpOmrCBHlnrW2kBH36pEH8zM4ybjpvI5VR_IQ?e=KwrbaA" rel="nofollow noreferrer">Sample project</a></p>
  <p>Here are my polimorhic models</p>
  <pre>namespace SwashbuckleTest.Models
  {
      public interface ITypeDiscriminator
      {
          string TypeDiscriminator { get; }
      }
  
      public abstract class SurveyStep : ITypeDiscriminator
      {
          public virtual string Id { get; set; }
          public string TypeDiscriminator =&gt; GetType().Name;
      }
  
      public abstract class SurveyStepResult : ITypeDiscriminator
      {
          public string Id { get; set; }
  
          public string TypeDiscriminator =&gt; GetType().Name;
      }
  
      public class BoolStep : SurveyStep
      {
          private string _id;
  
          public BoolStep()
          {
              ResultObject = new BoolStepResult();
          }
  
          public override string Id
          {
              get =&gt; _id;
              set
              {
                  _id = value;
                  ResultObject.Id = value;
              }
          }
  
          public string Question { get; set; }
  
          public BoolStepResult ResultObject { get; }
      }
  
      public class BoolStepResult : SurveyStepResult
      {
          public bool Value { get; set; }
      }
  }
  </pre>
  <p>Here other models</p>
  <pre>namespace SwashbuckleTest.Models
  {
      public abstract class SomeBaseModel
      {
          public string BaseValue { get; set; }
      }
  
      public class SomeConcreteModel : SomeBaseModel
      {
          public int ConcreteValue { get; set; }
      }
  }
  </pre>
  <p>and configurations I have tried</p>
  <pre>options.UseAllOfToExtendReferenceSchemas();
  options.GeneratePolymorphicSchemas(t =&gt;
  {
      var types = t.Is&lt;SurveyStep&gt;() ? new List&lt;Type&gt;() {typeof(BoolStep)}
          : t.Is&lt;SurveyStepResult&gt;() ? new List&lt;Type&gt;() {typeof(BoolStepResult)}
          : null;
      return types;
  } , t =&gt; t.Is&lt;ITypeDiscriminator&gt;() ? nameof(ITypeDiscriminator.TypeDiscriminator).ToCamelCase() : null);
  
  // or
  options.GeneratePolymorphicSchemas(discriminatorSelector: t =&gt; t.Is&lt;ITypeDiscriminator&gt;() ? nameof(ITypeDiscriminator.TypeDiscriminator).ToCamelCase() : null);
  </pre>