使用 Swashbuckle 显示作为自定义类型的模型属性的描述

Show descriptions for model properties which are custom types using Swashbuckle

我有这个型号:

public class Order {

  /// <summary>
  /// The customer.
  /// </summary>
  public Customer Customer { get; set; }

}

public class Customer {

  /// <summary>
  /// This is not shown.                 <---
  /// </summary>
  public int Id { get; set; }

  /// <summary>
  /// This is not shown.                 <---
  /// </summary>
  public string Name { get; set; }

}

Customer class 是在单独的程序集中定义的。

swagger ui 不显示 Customer 模型的 IdName 属性的描述。

我尝试了 these options,但没有帮助:

options.UseAllOfToExtendReferenceSchemas();
options.UseAllOfForInheritance();

我该如何解决这个问题?

必须包含所有 XML 文件,而不仅仅是入口程序集的文件。

var dir = AppContext.BaseDirectory;
var paths = Directory.GetFiles(dir, "*.xml", SearchOption.TopDirectoryOnly);
foreach (var path in paths) o.IncludeXmlComments(path);