GodelTech.Microservices.Swagger
8.1.0
dotnet add package GodelTech.Microservices.Swagger --version 8.1.0
NuGet\Install-Package GodelTech.Microservices.Swagger -Version 8.1.0
<PackageReference Include="GodelTech.Microservices.Swagger" Version="8.1.0" />
paket add GodelTech.Microservices.Swagger --version 8.1.0
#r "nuget: GodelTech.Microservices.Swagger, 8.1.0"
// Install GodelTech.Microservices.Swagger as a Cake Addin #addin nuget:?package=GodelTech.Microservices.Swagger&version=8.1.0 // Install GodelTech.Microservices.Swagger as a Cake Tool #tool nuget:?package=GodelTech.Microservices.Swagger&version=8.1.0
GodelTech.Microservices.Swagger
Overview
GodelTech.Microservices.Swagger project provides initializer which configures Swagger endpoinds and Swagger UI. Default configuration looks as follows:
- Swagger UI can be found at http://yourwebsite.com/swagger/index.html
- Swagger document can be found at http://yourwebsite/swagger/v1/swagger.json
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. |
Links
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 | Versions 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. |
-
net6.0
- GodelTech.Microservices.Core (>= 8.1.0)
- Swashbuckle.AspNetCore (>= 6.6.2)
- Swashbuckle.AspNetCore.Annotations (>= 6.6.2)
-
net7.0
- GodelTech.Microservices.Core (>= 8.1.0)
- Swashbuckle.AspNetCore (>= 6.6.2)
- Swashbuckle.AspNetCore.Annotations (>= 6.6.2)
-
net8.0
- GodelTech.Microservices.Core (>= 8.1.0)
- Swashbuckle.AspNetCore (>= 6.6.2)
- Swashbuckle.AspNetCore.Annotations (>= 6.6.2)
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.1.0 | 358 | 7/2/2024 | |
8.0.1 | 2,306 | 1/20/2024 | |
8.0.0 | 105 | 1/19/2024 | |
3.0.0 | 1,907 | 9/28/2023 | |
2.7.0 | 6,911 | 11/2/2022 | |
2.6.0 | 397 | 10/18/2022 | |
2.5.0 | 4,160 | 7/31/2022 | |
2.4.1 | 418 | 7/31/2022 | |
2.4.0 | 542 | 7/7/2022 | |
2.3.1 | 510 | 6/8/2022 | |
2.3.0 | 492 | 4/4/2022 | |
2.2.0 | 436 | 4/3/2022 | |
2.1.0 | 451 | 1/29/2022 | |
2.0.0 | 497 | 1/27/2022 | |
1.3.1 | 8,510 | 10/6/2020 | |
1.3.0 | 473 | 9/11/2020 | |
1.2.0 | 579 | 7/18/2020 | |
1.1.0 | 431 | 7/15/2020 | |
1.0.6 | 482 | 5/12/2020 | |
1.0.5 | 452 | 5/12/2020 | |
1.0.4 | 481 | 5/10/2020 | |
1.0.3 | 477 | 5/4/2020 | |
1.0.2 | 624 | 5/3/2020 | |
1.0.1-rc1 | 365 | 5/3/2020 |