Is it possible to version by action/endpoint instead of controller? #941
Replies: 2 comments 4 replies
-
Asp.Versioning.Mvc is the correct library for MVC Core. Supporting legacy clients that are not API version-aware is a certainly a supported scenario. I'm not sure why you would want to use
|
Beta Was this translation helpful? Give feedback.
-
I think this may just be a larger misunderstanding on my part of of how versioning works, and there will possibly be an usse with both LowestImplemented and CurrentImplementation. Controller (version 1): With CurrentVersionSelector Controller/GetFoo would see the most current implementation of GetFoo is version 1 and call that endpoint, but the behavior I'm seeing is that tries to call it on the version 2 controller. I'm assuming that Lowest implemented would have the opposite problem and if I tried to call GetBar, it would use version 1 and error out. So mostly I'm just asking is there a set up that can find the latest version an action is implemented in instead of just assuming it is implemented in all versions? Thanks for the other info btw, I didn't change the startup type in net50 because the web testing host wouldn't work with a program startup, I'm not sure if it's been fixed yet. I'll have to look more into grouping, I think that was in to fix something unexpected with swagger that ended up actually being a different issue. |
Beta Was this translation helpful? Give feedback.
-
I have 2 controllers with different versions (1.0, 2.0), and the same name, in different namespaces. I'm using the CurrentImplementationApiVersionSelector because versioning is being tacked on to a legacy project moving forward. The issue is that when no version is provided in the request any of the actions in the 1.0 controller that don't have an implementation in the 2.0 controller return a 400 because the metadata on the action processed by CurrentImplementationApiVersionSelector has both versions.
Is there an existing convention or convention I can remove to make only actions that share the same url template be considered when adding implementated versions metadata? Or would it be reasonable to make the CurrentImplementationApiVersionSelector smart enough to find the actual route of the highest versioned implementation of an action?
Also, I'm using the MVC library, but setting the controllers up via MapControllers in UseEndpoints. It's not clear from the current examples if that is a valid use-case, or which library it should use. So maybe the implementation specifically for endpoints could be used to do this?
.net version: net60
Libraries: Asp.Versioning.Mvc, Asp.Versioning.Mvc.ApiExplorer 6.3.1
Service set up code
App set up code
Beta Was this translation helpful? Give feedback.
All reactions