Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle
8.2.0
dotnet add package Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle --version 8.2.0
NuGet\Install-Package Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle -Version 8.2.0
<PackageReference Include="Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle" Version="8.2.0" />
paket add Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle --version 8.2.0
#r "nuget: Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle, 8.2.0"
// Install Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle as a Cake Addin #addin nuget:?package=Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle&version=8.2.0 // Install Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle as a Cake Tool #tool nuget:?package=Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle&version=8.2.0
OpenApi - Swashbuckle
This package provides extensions and filters for OpenAPI (Swagger) with version support using Swashbuckle.
Setup
Nuget package
First, install NuGet. Then, install Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle from the package manager console:
PM> Install-Package Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle
.NET CLI:
First, install .NET CLI. Then, install Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle from the .NET CLI:
dotnet add package Encamina.Enmarcha.AspNet.OpenApi.Swashbuckle
How to use
IServiceCollectionExtensions
IServiceCollectionExtensions
is a static class that provides extension methods for IServiceCollection
to add and configure services for OpenAPI (Swagger) with version support.
Usage
You can use the methods in this class as follows:
IServiceCollection services = new ServiceCollection();
IConfiguration configuration = new ConfigurationBuilder().Build();
services.AddVersionSwaggerGenConfigureOptions(configuration);
IServiceCollection services = new ServiceCollection();
Action<VersionSwaggerGenOptions> options = opts =>
{
opts.Title = "CUSTOM REST API"; // Title for the OpenAPI document when using version support.
};
services.AddVersionSwaggerGenConfigureOptions(options);
Methods
AddVersionSwaggerGenConfigureOptions(this IServiceCollection services, IConfiguration configuration)
: Adds version support for the generation of OpenAPI documents using configuration parameters from the current set of key-value application configuration. It returns theIServiceCollection
for chaining additional calls.AddVersionSwaggerGenConfigureOptions(this IServiceCollection services, Action<VersionSwaggerGenOptions> options)
: Adds version support for the generation of OpenAPI documents using an action to configure option parameters. It returns theIServiceCollection
for chaining additional calls.AddVersionSwaggerGenConfigureOptions(this IServiceCollection services)
: Adds version support for the generation of OpenAPI documents. It returns theIServiceCollection
for chaining additional calls.
Filters
ApiKeyHeaderOperationFilter
ApiKeyHeaderOperationFilter
is a class that implements the IOperationFilter
interface. It's used to add an API key header to the OpenAPI (Swagger) documentation.
Usage
To use this class, you need to create an instance and pass it to the Swagger configuration:
services.AddSwaggerGen(c =>
{
c.OperationFilter<ApiKeyHeaderOperationFilter>("YourHeaderApiKey", "YourDescription");
});
Constructor
ApiKeyHeaderOperationFilter(string headerApiKey)
: Initializes a new instance of the class with the given header API key name and a default description.ApiKeyHeaderOperationFilter(string headerApiKey, string description)
: Initializes a new instance of the class with the given header API key name and description.
Methods
Apply(OpenApiOperation operation, OperationFilterContext context)
: Applies the operation filter to the OpenAPI operation. It adds a newOpenApiParameter
to the operation's parameters, representing the API key header.
DefaultValuesOperationFilter
This C# code defines a class DefaultValuesOperationFilter that implements the IOperationFilter interface. This class is used to enrich the generated OpenAPI (Swagger) documents with default values for parameters.
DefaultValuesOperationFilter
is a class that implements the IOperationFilter
interface. It's used to enrich the generated OpenAPI (Swagger) documents with default values for parameters.
Usage
To use this class, you need to create an instance and pass it to the Swagger configuration:
services.AddSwaggerGen(c =>
{
c.OperationFilter<DefaultValuesOperationFilter>();
});
Methods
Apply(OpenApiOperation operation, OperationFilterContext context)
: Applies the operation filter to the OpenAPI operation. It adds default values to the operation's parameters and removes unsupported content types from the operation's responses.
VersionSwaggerGenConfigureOptions
This C# code defines a class VersionSwaggerGenConfigureOptions that implements the IConfigureOptions<SwaggerGenOptions> interface. This class is used to configure Swagger generation options for versioned OpenAPI documents.
VersionSwaggerGenConfigureOptions
is a class that implements the IConfigureOptions<SwaggerGenOptions>
interface. It's used to configure Swagger generation options for versioned OpenAPI documents.
Usage
To use this class, you need to create an instance and pass it to the Swagger configuration:
services.AddSwaggerGen(c =>
{
c.Configure<VersionSwaggerGenConfigureOptions>();
});
Constructor
VersionSwaggerGenConfigureOptions(IApiVersionDescriptionProvider apiVersionDescriptionProvider, IOptions<VersionSwaggerGenOptions> options)
: Initializes a new instance of the class with the given API version description provider and configuration options.
Methods
Configure(SwaggerGenOptions options)
: Configures the Swagger generation options. It adds a newOpenApiInfo
to the Swagger documentation for each API version.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- CommunityToolkit.Diagnostics (>= 8.2.2)
- Encamina.Enmarcha.Core (>= 8.2.0)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.7.3)
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.2.0 | 285 | 10/22/2024 |
8.2.0-preview-01-m01 | 103 | 9/17/2024 |
8.1.9-preview-02 | 58 | 10/22/2024 |
8.1.9-preview-01 | 315 | 10/4/2024 |
8.1.8 | 627 | 9/23/2024 |
8.1.8-preview-07 | 203 | 9/12/2024 |
8.1.8-preview-06 | 253 | 9/11/2024 |
8.1.8-preview-05 | 85 | 9/10/2024 |
8.1.8-preview-04 | 427 | 8/16/2024 |
8.1.8-preview-03 | 178 | 8/13/2024 |
8.1.8-preview-02 | 108 | 8/13/2024 |
8.1.8-preview-01 | 111 | 8/12/2024 |
8.1.7 | 100 | 8/7/2024 |
8.1.7-preview-09 | 191 | 7/3/2024 |
8.1.7-preview-08 | 83 | 7/2/2024 |
8.1.7-preview-07 | 83 | 6/10/2024 |
8.1.7-preview-06 | 77 | 6/10/2024 |
8.1.7-preview-05 | 85 | 6/6/2024 |
8.1.7-preview-04 | 94 | 6/6/2024 |
8.1.7-preview-03 | 88 | 5/24/2024 |
8.1.7-preview-02 | 83 | 5/10/2024 |
8.1.7-preview-01 | 94 | 5/8/2024 |
8.1.6 | 1,028 | 5/7/2024 |
8.1.6-preview-08 | 60 | 5/2/2024 |
8.1.6-preview-07 | 84 | 4/29/2024 |
8.1.6-preview-06 | 560 | 4/26/2024 |
8.1.6-preview-05 | 101 | 4/24/2024 |
8.1.6-preview-04 | 119 | 4/22/2024 |
8.1.6-preview-03 | 88 | 4/22/2024 |
8.1.6-preview-02 | 155 | 4/17/2024 |
8.1.6-preview-01 | 181 | 4/15/2024 |
8.1.5 | 111 | 4/15/2024 |
8.1.5-preview-15 | 100 | 4/10/2024 |
8.1.5-preview-14 | 93 | 3/20/2024 |
8.1.5-preview-13 | 78 | 3/18/2024 |
8.1.5-preview-12 | 101 | 3/13/2024 |
8.1.5-preview-11 | 85 | 3/13/2024 |
8.1.5-preview-10 | 98 | 3/13/2024 |
8.1.5-preview-09 | 95 | 3/12/2024 |
8.1.5-preview-08 | 78 | 3/12/2024 |
8.1.5-preview-07 | 92 | 3/8/2024 |
8.1.5-preview-06 | 343 | 3/8/2024 |
8.1.5-preview-05 | 84 | 3/7/2024 |
8.1.5-preview-04 | 73 | 3/7/2024 |
8.1.5-preview-03 | 81 | 3/7/2024 |
8.1.5-preview-02 | 200 | 2/28/2024 |
8.1.5-preview-01 | 171 | 2/19/2024 |
8.1.4 | 275 | 2/15/2024 |
8.1.3 | 109 | 2/13/2024 |
8.1.3-preview-07 | 83 | 2/13/2024 |
8.1.3-preview-06 | 111 | 2/12/2024 |
8.1.3-preview-05 | 101 | 2/9/2024 |
8.1.3-preview-04 | 101 | 2/8/2024 |
8.1.3-preview-03 | 105 | 2/7/2024 |
8.1.3-preview-02 | 78 | 2/2/2024 |
8.1.3-preview-01 | 82 | 2/2/2024 |
8.1.2 | 122 | 2/1/2024 |
8.1.2-preview-9 | 90 | 1/22/2024 |
8.1.2-preview-8 | 78 | 1/19/2024 |
8.1.2-preview-7 | 79 | 1/19/2024 |
8.1.2-preview-6 | 78 | 1/19/2024 |
8.1.2-preview-5 | 83 | 1/19/2024 |
8.1.2-preview-4 | 88 | 1/19/2024 |
8.1.2-preview-3 | 83 | 1/18/2024 |
8.1.2-preview-2 | 84 | 1/18/2024 |
8.1.2-preview-16 | 85 | 1/31/2024 |
8.1.2-preview-15 | 73 | 1/31/2024 |
8.1.2-preview-14 | 89 | 1/25/2024 |
8.1.2-preview-13 | 91 | 1/25/2024 |
8.1.2-preview-12 | 94 | 1/23/2024 |
8.1.2-preview-11 | 83 | 1/23/2024 |
8.1.2-preview-10 | 84 | 1/22/2024 |
8.1.2-preview-1 | 86 | 1/18/2024 |
8.1.1 | 120 | 1/18/2024 |
8.1.0 | 97 | 1/18/2024 |
8.0.3 | 159 | 12/29/2023 |
8.0.1 | 155 | 12/14/2023 |
8.0.0 | 146 | 12/7/2023 |
6.0.4.3 | 110 | 12/29/2023 |
6.0.4.2 | 122 | 12/20/2023 |
6.0.4.1 | 186 | 12/19/2023 |
6.0.4 | 159 | 12/4/2023 |
6.0.3.20 | 133 | 11/27/2023 |
6.0.3.19 | 122 | 11/22/2023 |