0

Is there a way how to make Swashbuckle take the XML Comments for properties which hide those in the base class?

class Base {

  /// <summary>
  /// This comment shows in swagger UI.
  /// </summary>
  public int Value { get; set; }
}

class Model: Base {
  /// <summary>
  /// This comment is not visible in swagger UI.
  /// </summary>
  public new int Value { get; set; }
}

Is there any workaround, e.g. using a kind of SchemaFilter?

UPDATED The above simple example works as expected.

Our problem is probably caused by a wrong configuration of the IncludeXmlComments option as our models come from multiple assemblies. I found a related discussion on GitHub

el peregrino
  • 741
  • 5
  • 9
  • Does this answer your question? [How to configure Swashbuckle to ignore property on model](https://stackoverflow.com/questions/41005730/how-to-configure-swashbuckle-to-ignore-property-on-model) – Peter Csala Jan 15 '21 at 17:15
  • 1
    When I test, I see the comments for derived Model (not Base), which I understand is what you want. Have reproduced in multiple asp.net core test apps. – John Arlen Jan 15 '21 at 17:34
  • As a workaround... I would suggest to to put you base class in some other dll than your model class. Then you add only the model dll to swagger with `c.IncludeXmlComments(filePath); ` – lag Jan 15 '21 at 19:26
  • I confused myself when analyzing the code. I'll update the question. – el peregrino Jan 15 '21 at 20:15

0 Answers0