You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a common scenario to use a namespace in the implementation of services as versioning boundary. By configuring API versioning to use this convention, any controller placed in a convention-based API version namespace will automatically have that API version applied.
Design
In order for the feature to work, the namespace name must still conform to the API version format so that it can be parsed. The language-neutral format in BNF will be:
By default, API versions will be considered supported. If the controller is decorated with the ObsoleteAttribute, then the API version inferred from the containing namespace will be considered deprecated.
Tooling Integration
Compilers such as Visual C# and Visual Basic use folders to automatically define namespace hierarchies. Tools such Visual Studio will attempt to convert invalid namespace names to their safe equivalents. Unfortunately, the . character is considered a namespace delimiter. This character should be changed to _ so that newly added files have the correct format. In addition, Visual Studio will add a leading _ if the folder name starts with a number. Since a leading character will be required, the format will require that the first character must be v or V.
Additional Considerations
The design should consider other types of conventions. This might be an extension of the existing convention features.
The text was updated successfully, but these errors were encountered:
commonsensesoftware
changed the title
[Feature] Support API Version Using Namespace Convention
Support API Version Using Namespace Convention
Apr 16, 2018
Things have progressed nicely. I might be able to squeeze out a beta by end of week for folks to start trying out. I'm testing out the routing changes to see how it affects other middleware. It's a rather slow and manual process. =/
To give those following this a sense of how this enhancement will work, you'll now be able to create and define your own conventions (a la the new IControllerConvention interface) in addition to the standard conventions. In this release, the only new convention will be the version by namespace convention. The setup will look like:
Uh oh!
There was an error while loading. Please reload this page.
Overview
It's a common scenario to use a namespace in the implementation of services as versioning boundary. By configuring API versioning to use this convention, any controller placed in a convention-based API version namespace will automatically have that API version applied.
Design
In order for the feature to work, the namespace name must still conform to the API version format so that it can be parsed. The language-neutral format in BNF will be:
'v' | 'V' : [<year> '-' <month> '-' <day>] : [<major[.minor]>] : [<status>]
Examples
Contoso.Api.v1.Controllers
→ 1.0Contoso.Api.v1_1.Controllers
→ 1.1Contoso.Api.v0_9_Beta.Controllers
→ 0.9-BetaContoso.Api.v20180401.Controllers
→ 2018-04-01Contoso.Api.v2018_04_01.Controllers
→ 2018-04-01Contoso.Api.v2018_04_01_Beta.Controllers
→ 2018-04-01-BetaContoso.Api.v2018_04_01_1_0_Beta.Controllers
→ 2018-04-01.1.0-BetaBy default, API versions will be considered supported. If the controller is decorated with the ObsoleteAttribute, then the API version inferred from the containing namespace will be considered deprecated.
Tooling Integration
Compilers such as Visual C# and Visual Basic use folders to automatically define namespace hierarchies. Tools such Visual Studio will attempt to convert invalid namespace names to their safe equivalents. Unfortunately, the
.
character is considered a namespace delimiter. This character should be changed to_
so that newly added files have the correct format. In addition, Visual Studio will add a leading_
if the folder name starts with a number. Since a leading character will be required, the format will require that the first character must bev
orV
.Additional Considerations
The design should consider other types of conventions. This might be an extension of the existing convention features.
The text was updated successfully, but these errors were encountered: