JM.Asp.Versioning
1.0.0
dotnet add package JM.Asp.Versioning --version 1.0.0
NuGet\Install-Package JM.Asp.Versioning -Version 1.0.0
<PackageReference Include="JM.Asp.Versioning" Version="1.0.0" />
paket add JM.Asp.Versioning --version 1.0.0
#r "nuget: JM.Asp.Versioning, 1.0.0"
// Install JM.Asp.Versioning as a Cake Addin #addin nuget:?package=JM.Asp.Versioning&version=1.0.0 // Install JM.Asp.Versioning as a Cake Tool #tool nuget:?package=JM.Asp.Versioning&version=1.0.0
JM.Asp.Versioning
This is a simple convention for versioning web APIs. It extends [Asp.Versioning].
The objective of this package is to avoid duplicating code to always maintain endpoints from previous versions that are still used in the most recent version of the API. This package basically controls the lifecycle of the endpoints. So as long as a controller or action is not removed it will be contained in the latest version of the api.
Getting Started
(1) Dependency Injection.
2.1) Extended options.
In addition to the options available in "AddApiVersioning" in the Asp.Versioning package, this package provides the following options described below.
- AutoDetectApiVersions: If activated, it allows the package to automatically identify the versions in use in the api.
- Assembly: Necessary to identify where you will search for controllers. Works in conjunction with 'AutoDetectApiVersions' enabled.
- StartApiVersion and CurrentApiVersion: If you want to manually control the versions of your api with this package, simply enter the values in these properties.
2.2) Using the package.
builder.Services.AddApiVersioningLifeCycle(x =>
{
x.Assembly = Assembly.GetExecutingAssembly();
x.AutoDetectApiVersions = true;
x.ReportApiVersions = true;
x.AssumeDefaultVersionWhenUnspecified = true;
x.DefaultApiVersion = new Asp.Versioning.ApiVersion(3.0);
});
(2) Features
The attributes below are available for use in classes and method on controllers.
2.1) Attribute ApiVersionInclude
This attribute indicates that method or controller class is being included in the specified version.
[ApiVersionInclude(2)]
2.2) Attribute ApiVersionRemove
This attribute indicates that method or controller class is being removed in the specified version.
[ApiVersionRemove(3.1)]
Example
The "samples" folder contains a project with a complete example of using the package.
v1
v2
v2.1
v3
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
- Asp.Versioning.Mvc (>= 6.4.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 6.4.0)
-
net7.0
- Asp.Versioning.Mvc (>= 7.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 7.1.0)
-
net8.0
- Asp.Versioning.Mvc (>= 7.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 7.1.0)
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 |
---|---|---|
1.0.0 | 239 | 11/25/2023 |