Unchase.Swashbuckle.AspNetCore.Extensions 1.0.0

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.0                
NuGet\Install-Package Unchase.Swashbuckle.AspNetCore.Extensions -Version 1.0.0                
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.0" />                
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.0                
#r "nuget: Unchase.Swashbuckle.AspNetCore.Extensions, 1.0.0"                
#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.0

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

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 (16)

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.

Pipoburgos.SharedKernel.Api

C# DDD Distributed Services Layer

Tradeber.AbpCore.ServiceFabric

tradeber 基础设施库

Pipoburgos.SharedKernel.Api.Gateway

C# DDD Distributed Services Layer

Xinghe.Utility

XH基础库(内部使用)

GitHub repositories (4)

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

Repository Stars
exceptionless/Exceptionless
Exceptionless application
meysamhadeli/booking-microservices
Practical microservices, built with .Net 9, DDD, CQRS, Event Sourcing, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
mehdihadeli/food-delivery-microservices
🍔 A practical and imaginary food delivery microservices, built with .Net 8, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
aehyok/.NET8.0
net8.0 efcore mysql redis rabbitmq 微服务
Version Downloads Last updated
2.7.2 1,735 12/17/2024
2.7.1 2,233,520 12/11/2022
2.7.0 1,712 12/10/2022
2.6.12 1,216,458 10/5/2021
2.6.11 9,502 9/29/2021
2.6.9 35,234 8/30/2021
2.6.8 3,668 8/26/2021
2.6.7 855 8/26/2021
2.6.6 10,067 8/26/2021
2.6.5 902 8/26/2021
2.6.4 926 8/26/2021
2.6.3 924 8/26/2021
2.6.2 1,557 8/26/2021
2.6.0 437,657 3/6/2021
2.5.2 108,803 2/9/2021
2.5.1 3,222 2/5/2021
2.5.0 222,800 10/15/2020
2.4.1 32,345 10/13/2020
2.4.0 1,952 10/11/2020
2.3.13 18,311 10/7/2020
2.3.12 5,029 9/21/2020
2.3.11 2,341 9/17/2020
2.3.10 73,585 7/29/2020
2.3.9 1,721 7/28/2020
2.3.8 30,358 7/6/2020
2.3.7 1,083 7/6/2020
2.3.6 1,088 7/6/2020
2.3.5 1,086 7/6/2020
2.3.4 124,417 6/11/2020
2.3.3 197,545 3/25/2020
2.3.2 1,170 3/25/2020
2.3.1 1,052 3/25/2020
2.3.0 2,595 3/22/2020
2.2.6 2,484 3/22/2020
2.2.5 29,494 3/2/2020
2.2.4 1,128 3/2/2020
2.2.3 1,107 3/2/2020
2.2.2 1,115 2/29/2020
2.2.1 1,130 2/29/2020
2.2.0 1,222 2/28/2020
2.1.7 11,479 2/21/2020
2.1.6 1,174 2/21/2020
2.1.5 1,134 2/21/2020
2.1.4 1,407 2/20/2020
2.1.3 1,129 2/20/2020
2.1.2 1,084 2/20/2020
2.1.1 1,119 2/19/2020
2.1.0 1,168 2/19/2020
2.0.1 1,183 2/18/2020
2.0.0 12,469 2/8/2020
1.1.4 5,308 12/26/2019
1.1.3 1,331 11/29/2019
1.1.2 1,273 11/22/2019
1.1.1 6,461 5/13/2019
1.1.0 1,210 5/7/2019
1.0.2 1,159 5/1/2019
1.0.0 3,405 5/1/2019