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
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="JM.Asp.Versioning" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JM.Asp.Versioning --version 1.0.0
#r "nuget: JM.Asp.Versioning, 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 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

Example_V1

v2

Example_V2

v2.1

Example_V2.1

v3

Example_V3

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
1.0.0 208 11/25/2023