Unchase.Swashbuckle.AspNetCore.Extensions 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Unchase.Swashbuckle.AspNetCore.Extensions --version 1.0.2
NuGet\Install-Package Unchase.Swashbuckle.AspNetCore.Extensions -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Unchase.Swashbuckle.AspNetCore.Extensions" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Unchase.Swashbuckle.AspNetCore.Extensions --version 1.0.2
#r "nuget: Unchase.Swashbuckle.AspNetCore.Extensions, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Unchase.Swashbuckle.AspNetCore.Extensions as a Cake Addin
#addin nuget:?package=Unchase.Swashbuckle.AspNetCore.Extensions&version=1.0.2

// Install Unchase.Swashbuckle.AspNetCore.Extensions as a Cake Tool
#tool nuget:?package=Unchase.Swashbuckle.AspNetCore.Extensions&version=1.0.2

Unchase Swashbuckle Asp.Net Core Extensions Logo

Unchase Swashbuckle Asp.Net Core Extensions is a library contains a bunch of extensions (filters) for Swashbuckle.AspNetCore.

The project is developed and maintained by Nikolay Chebotov (Unchase).

Getting Started

To use the extensions:

  1. First install the NuGet package:
Install-Package Unchase.Swashbuckle.AspNetCore.Extensions
  1. In the ConfigureServices method of Startup.cs, inside your AddSwaggerGen call, enable whichever extensions (filters) you need:
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddMvc();

    services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
        
        options.SwaggerDoc("v1", new Info {Title = "My API", Version = "v2"});

        // Add filters to fix enums
        options.EnumsWithValuesFixFilters(true);

        // Include xml-comments from xml-file generated by project
        var filePath = Path.Combine(AppContext.BaseDirectory, "WebApi2.0-Swashbuckle.xml");
        options.IncludeXmlComments(filePath);
    });
}

Builds status

Build status

Features

  • Add an output enums integer values with there strings like 0 = FirstEnumValue without a StringEnumConverter in swaggerUI and schema (by default enums will output only their integer values)

  • Add description to each enum value that has an [Description] attribute in swaggerUI and schema

    In Swashbuckle SwaggerUI:

    Enum Description in SwaggerUI

    In schema parameters:

    Enum Description in Schema Parameters

    In schema definitions:

    Enum Description in Schema Definitions

    To show enum values descriptions you should use [Description] attribute in your code:

    /// <summary>
    /// Title enum.
    /// </summary>
    [DataContract]
    public enum Title
    {
        /// <summary>
        /// None.
        /// </summary>
        [Description("None enum description")]
        [EnumMember]
        None = 0,
    
        /// <summary>
        /// Miss.
        /// </summary>
        [Description("Miss enum description")]
        [EnumMember]
        Miss,
    
        /// <summary>
        /// Mr.
        /// </summary>
        [Description("Mr enum description")]
        [EnumMember]
        Mr
    }
    
  • Fix enum values in generated by NSwagStudio or Unchase OpenAPI Connected Service client classes:

    /// <summary>Sample Person title.
    /// 0 = None (None enum description)
    /// 1 = Miss (Miss enum description)
    /// 2 = Mr (Mr enum description)</summary>
    [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.35.0 (Newtonsoft.Json v11.0.0.0)")]
    public enum Title
    {
        None = 0,
    
        Miss = 1,
    
        Mr = 2,
    
    }
    
    [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.35.0 (Newtonsoft.Json v11.0.0.0)")]
    public enum SamplePersonRequestResponseTitle
    {
        None = 0,
    
        Miss = 1,
    
        Mr = 2,
    
    }
    

HowTos

Roadmap

See the changelog for the further development plans and version history.

Feedback

Please feel free to add your request a feature or report a bug. Thank you in advance!

Thank me!

If you like what I am doing and you would like to thank me, please consider:

Buy me a coffe!

Thank you for your support!


Copyright © 2019 Nikolay Chebotov (Unchase) - Provided under the Apache License 2.0.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on Unchase.Swashbuckle.AspNetCore.Extensions:

Package Downloads
Tessa.Web

TESSA library for building ASP.NET Core applications.

Tradeber.AbpCore.ServiceFabric

tradeber 基础设施库

Pipoburgos.SharedKernel.Api

C# DDD Distributed Services Layer

Pipoburgos.SharedKernel.Api.Gateway

C# DDD Distributed Services Layer

Xinghe.Utility

XH基础库(内部使用)

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Unchase.Swashbuckle.AspNetCore.Extensions:

Repository Stars
exceptionless/Exceptionless
Exceptionless application
meysamhadeli/booking-microservices
Practical microservices, built with .Net 8, DDD, CQRS, Event Sourcing, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
mehdihadeli/food-delivery-microservices
🍔 A practical food delivery microservices, built with .Net 7, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
Version Downloads Last updated
2.7.1 1,169,802 12/11/2022
2.7.0 900 12/10/2022
2.6.12 1,080,746 10/5/2021
2.6.11 8,933 9/29/2021
2.6.9 34,339 8/30/2021
2.6.8 3,588 8/26/2021
2.6.7 801 8/26/2021
2.6.6 10,008 8/26/2021
2.6.5 847 8/26/2021
2.6.4 867 8/26/2021
2.6.3 872 8/26/2021
2.6.2 1,439 8/26/2021
2.6.0 396,711 3/6/2021
2.5.2 101,359 2/9/2021
2.5.1 3,168 2/5/2021
2.5.0 207,632 10/15/2020
2.4.1 29,761 10/13/2020
2.4.0 1,870 10/11/2020
2.3.13 15,934 10/7/2020
2.3.12 4,901 9/21/2020
2.3.11 2,294 9/17/2020
2.3.10 53,201 7/29/2020
2.3.9 1,660 7/28/2020
2.3.8 30,186 7/6/2020
2.3.7 1,019 7/6/2020
2.3.6 1,031 7/6/2020
2.3.5 1,014 7/6/2020
2.3.4 119,845 6/11/2020
2.3.3 194,774 3/25/2020
2.3.2 1,113 3/25/2020
2.3.1 998 3/25/2020
2.3.0 2,536 3/22/2020
2.2.6 2,429 3/22/2020
2.2.5 28,865 3/2/2020
2.2.4 1,079 3/2/2020
2.2.3 1,053 3/2/2020
2.2.2 1,054 2/29/2020
2.2.1 1,064 2/29/2020
2.2.0 1,165 2/28/2020
2.1.7 9,978 2/21/2020
2.1.6 1,118 2/21/2020
2.1.5 1,089 2/21/2020
2.1.4 1,348 2/20/2020
2.1.3 1,070 2/20/2020
2.1.2 1,043 2/20/2020
2.1.1 1,080 2/19/2020
2.1.0 1,119 2/19/2020
2.0.1 1,125 2/18/2020
2.0.0 12,405 2/8/2020
1.1.4 4,683 12/26/2019
1.1.3 1,264 11/29/2019
1.1.2 1,213 11/22/2019
1.1.1 6,391 5/13/2019
1.1.0 1,157 5/7/2019
1.0.2 1,106 5/1/2019
1.0.0 2,922 5/1/2019