GodelTech.Microservices.Swagger 8.0.1

dotnet add package GodelTech.Microservices.Swagger --version 8.0.1
NuGet\Install-Package GodelTech.Microservices.Swagger -Version 8.0.1
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="GodelTech.Microservices.Swagger" Version="8.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GodelTech.Microservices.Swagger --version 8.0.1
#r "nuget: GodelTech.Microservices.Swagger, 8.0.1"
#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 GodelTech.Microservices.Swagger as a Cake Addin
#addin nuget:?package=GodelTech.Microservices.Swagger&version=8.0.1

// Install GodelTech.Microservices.Swagger as a Cake Tool
#tool nuget:?package=GodelTech.Microservices.Swagger&version=8.0.1

GodelTech.Microservices.Swagger

Overview

GodelTech.Microservices.Swagger project provides initializer which configures Swagger endpoinds and Swagger UI. Default configuration looks as follows:

Default behavior can be overriden by changing values of intializer's Options property or by deriving your customer initializer from SwaggerInitializer.

Quick Start

Simplest usage of swagger initializer may look as follows:

    public sealed class Startup : MicroserviceStartup
    {
        public Startup(IConfiguration configuration)
            : base(configuration)
        {

        }

        protected override IEnumerable<IMicroserviceInitializer> CreateInitializers()
        {
            ...
            yield return new SwaggerInitializer(
                options =>
                {
                    options.DocumentTitle = "Demo API";
                    options.DocumentVersion = "v1";
                    options.AuthorizationUrl = new Uri("http://authorize.url");
                    options.TokenUrl = new Uri("http://token.url");
                    options.Scopes = new Dictionary<string, string>
                    {
                        { "Scope1", "Scope description" }
                    };
                }
            );
            ...
        }
    }

This code snippet adds swagger endpoints to your application and exposes document for once version of your API.

Configuration Options

Easiest way to configure initializer is to use properties of SwaggerInitializerOptions class. The following table contains list of available settings:

Property Description
DocumentTitle Title of your Swagger document. Default value is API.
DocumentVersion Version of API exposed by service. Default value is v1.
XmlCommentsFilePath (Optional) Path XML comments provides by project build. This information is used by Swagger generator to provide description of exposed models and properties.
AuthorizationUrl (Optional) Identity provider endpoint used by Swagger UI to authorize user. If this value is not defined some OAuth flows might not be available in Swagger UI.
TokenUrl (Optional) Identity provider token endpont used by Swagger UI to obtain token used to invoke API endpoints. If this endpoint is not available some OAuth flows might not be available in Swagger UI.

Full control over SwaggerInitializer can be obtained by defined child class. The following protected methods are avaible:

Method Description
ConfigureSwaggerGenOptions This method is passed as parameter to services.AddSwaggerGen(). It configures security definitions based on values defined in Options property. Additionally it adds support of annotations, injects security schemes to endpoint definitions and enables XML comments support.
ConfigureSwaggerOptions This method is passed as parameter to app.UseSwagger(). This method configures location of Swagger document uri.
ConfigureSwaggerUiOptions This method is passed as parameter to app.UseSwaggerUI(). This method configures route used by Swagger endpoint.

Current project is Swagger extension of Microservice Framework. You can find references to all available projects in core project of framework GodelTech.Microservices.Core. Extension is based on Swashbuckle.AspNetCore project.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.1 121 1/20/2024
8.0.0 76 1/19/2024
3.0.0 1,214 9/28/2023
2.7.0 5,235 11/2/2022
2.6.0 368 10/18/2022
2.5.0 4,129 7/31/2022
2.4.1 388 7/31/2022
2.4.0 511 7/7/2022
2.3.1 473 6/8/2022
2.3.0 465 4/4/2022
2.2.0 406 4/3/2022
2.1.0 418 1/29/2022
2.0.0 466 1/27/2022
1.3.1 7,368 10/6/2020
1.3.0 442 9/11/2020
1.2.0 546 7/18/2020
1.1.0 415 7/15/2020
1.0.6 452 5/12/2020
1.0.5 425 5/12/2020
1.0.4 454 5/10/2020
1.0.3 449 5/4/2020
1.0.2 596 5/3/2020
1.0.1-rc1 339 5/3/2020