unchase / Unchase.Swashbuckle.AspNetCore.Extensions

:hammer: A library contains a bunch of extensions (filters) for Swashbuckle.AspNetCore.
https://www.nuget.org/packages/Unchase.Swashbuckle.AspNetCore.Extensions
Apache License 2.0
115 stars 16 forks source link

Wiki/Docs: .UseAllOfToExtendReferenceSchemas() Necessary? #13

Closed DaleyKD closed 4 years ago

DaleyKD commented 4 years ago

I couldn't get any of your stuff to output documentation unless I use the options.UseAllOfToExtendReferenceSchemas() from Swashbuckle. I don't know if this needs to be added to the docs or not. Just thought I'd give you an FYI.

services.AddSwaggerGen(options =>
{
    options.SwaggerDoc("v1", apiInfo);
    options.UseAllOfToExtendReferenceSchemas();

    var xmlFile = $"{Assembly.GetEntryAssembly()?.GetName().Name}.xml";
    var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
    if (xmlFile != ".xml" && File.Exists(xmlPath))
    {
        options.IncludeXmlComments(xmlPath);
    }

    options.AddEnumsWithValuesFixFilters(services, o =>
    {
        o.ApplySchemaFilter = true;
        o.ApplyParameterFilter = true;
        o.ApplyDocumentFilter = true;
        o.IncludeDescriptions = true;
        o.DescriptionSource = DescriptionSources.DescriptionAttributesThenXmlComments;
        if (xmlFile != ".xml" && File.Exists(xmlPath))
        {
            o.IncludeXmlCommentsFrom(xmlPath);
        }
    });
});
unchase commented 4 years ago

I use the options.UseAllOfToExtendReferenceSchemas() in my work project. You should use it if you want to hide Paths and Definitions from OpenApi documentation correctly.