For anyone using Swashbuckle with ASP.NET, you can use the following code to have the $ref
construct put under the allOf
(just like the :
// do this wherever you are calling AddSwaggerGen()
ArgBuilder.Services.AddSwaggerGen(opts => {
opts.UseAllOfToExtendReferenceSchemas(); // add this line.
});
Now if you have a model with two properties of the same type, the individual descriptions for each field will show up in Swagger UI (e.g. below, both FooHeader
and BarHeader
are properties of type HttpHeader
and their descriptions show up):