1

I have this model:

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; }

}

The Customer class is defined in a separate assembly.

The swagger ui does not show descriptions for the Customer model's Id and Name properties.

I tried these options, which didn't help:

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

How can I fix this?

lonix
  • 14,255
  • 23
  • 85
  • 176
  • 1
    Hi @lonix, Which version of Swashbuckle you are using? For the nested Models missing descriptions, it seems that it is a known issue, and it has fixed in the latest version (v6 version), you could try to use it. Reference: [Nested Models Missing Descriptions](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1441) and [ xml annotation not working for properties in nested objects](https://github.com/domaindrivendev/Swashbuckle.WebApi/issues/86). – Zhi Lv Jul 13 '21 at 10:06
  • @ZhiLv Thanks! That lead me to the solution, see below. – lonix Oct 22 '21 at 08:12

1 Answers1

0

All XML files must be included, not just the one for the entry assembly.

var dir = AppContext.BaseDirectory;
var paths = Directory.GetFiles(dir, "*.xml", SearchOption.TopDirectoryOnly);
foreach (var path in paths) o.IncludeXmlComments(path);
lonix
  • 14,255
  • 23
  • 85
  • 176