I am using NSwag to generate an OpenApi3 spec from my controllers. I also use a custom implementation of IDocumentProcessor to generate models not included in the controllers. The post processor models share abstract classes with the controller methods. It seems like the models generated in the IDocumentProcessor duplicates the abstract classes. Is there any way to avoid this?
My IDocumentProcessor :
private class SwaggerDocumentProcessor : IDocumentProcessor
{
public void Process(DocumentProcessorContext context)
{
var assembly = Assembly.GetExecutingAssembly()
.GetReferencedAssemblies()
.FirstOrDefault(a => string.Equals(a.Name, "Api.Model", StringComparison.Ordinal));
if (assembly != null)
{
var loadedAssembly = Assembly.Load(assembly);
var types = loadedAssembly.GetTypes();
foreach (var type in types)
{
if (context.SchemaResolver.HasSchema(type, false)) continue;
if (type.IsClass)
{
context.SchemaGenerator.Generate(new JsonSchema(), type, context.SchemaResolver);
}
}
}
}
}
From what I can see, it seems like the duplicate is added because another class has the abstract class as a generic constraint
public class ActivityEvent<TModel> : EventBase where TModel : Activity