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
We want to make a V10.0 API version and we are using VersionByNamespaceConvention configuration. But it looks like that this is not supported (if you skip the date part).
I checked the Pattern used in the VersionByNamespaceConvention and it looks like "10" is matching the second group (month). And therefore it is not seen..
It will work if we use "V___10_0" as namespace; but that will be ugly.
I would prefer an option to configure that you only use major/minor convention..
or maybe a more easy way of fixing would be; first check if it has at least 8digits before date matching will be applied.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. You are correct. The issue is less about the pattern and more about how the results are used. Regardless, this is not the expected behavior and is a bug. The next major release has this entire implementation rewritten to not use regular expressions. It's not only faster, but avoids issues like this. I've added this specific test case (and it passes 😉)
I'll add this to the list to put in the next patch version. In the meantime, my recommendation would be to use your own custom convention to workaround the issue. That will prevent you from having to resort to ugly namespace components. Since the implementation is localized to your application, you don't have to add generic validation.
It would look something like:
publicclassCustomNamespaceConvention:IControllerConvention{publicboolApply(IControllerConventionBuilderbuilder,ControllerModelcontroller){varname=controller.ControllerType.Namespace;// extract from herevarversion=ApiVersion.Parse(name);vardeprecated=controller.Attributes.OfType<ObsoleteAttribute>().Any();if(deprecated){builder.HasDeprecatedApiVersion(version);}else{builder.HasApiVersion(version);}returntrue;}}
Honestly, you don't even have to parse it. You could have a dictionary that maps ApiVersion to namespace string. The choice is yours, but that should suffice as a bridge until the issue is fixed.
We want to make a V10.0 API version and we are using VersionByNamespaceConvention configuration. But it looks like that this is not supported (if you skip the date part).
I checked the Pattern used in the VersionByNamespaceConvention and it looks like "10" is matching the second group (month). And therefore it is not seen..
It will work if we use "V___10_0" as namespace; but that will be ugly.
I would prefer an option to configure that you only use major/minor convention..
or maybe a more easy way of fixing would be; first check if it has at least 8digits before date matching will be applied.
The text was updated successfully, but these errors were encountered: