【发布时间】:2021-07-12 12:25:16
【问题描述】:
我有这个模型:
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 类在单独的程序集中定义。
swagger ui 不显示 Customer 模型的 Id 和 Name 属性的描述。
options.UseAllOfToExtendReferenceSchemas();
options.UseAllOfForInheritance();
我该如何解决这个问题?
【问题讨论】:
-
嗨@lonix,您使用的是哪个版本的 Swashbuckle?对于嵌套模型缺少描述,似乎是一个已知问题,并且在最新版本(v6版本)中已经修复,您可以尝试使用它。参考:Nested Models Missing Descriptions 和 <summary> xml annotation not working for properties in nested objects。
-
@ZhiLv 谢谢!这让我找到了解决方案,见下文。
标签: c# asp.net-core swagger swagger-ui swashbuckle