-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Version Neutral Throwing 404 - DotNet 8.0 Upgrade #1116
Comments
+1 |
You mentioned you're upgrading from .NET 6, but you didn't say which version of API Versioning you were using. Based on the behavior you are describing, I'm guessing you are upgrading from Starting in API Versioning You specified The best choice would be to simply have your route template be It's not entirely clear me why a version-neutral endpoint should exist for an API version that doesn't exist anywhere else. That suggests that it's not actually version-neutral and instead just matches anything. An API, even a version-neutral one, that accepts any old well-formed API version seems nonsensical. I have witnessed teams run into problems when they realized they were matching client requests with versions specified that don't exist in their API. There be 🐉🐉🐉. An alternate approach is to move away from being version-neutral and instead have your health check support a fixed set of versions. This can be achieved several ways:
Remember that API versions must be explicit. Version-neutrality conveniently maps to any API version you define and also allows the omission of the API version as this is equivalent to matching an initial, unversioned endpoint. If it was really no versioning, then the attribute would have been called something like Hopefully, this wasn't a soapbox response. If you're using |
Is there an existing issue for this?
Describe the bug
In upgrading applications from DotNet 6.0 to DotNet 8.0 I encountered an issue with routing version neutrality.
My existing implementation has a neutral healthcheck controller that accomplishes the following:
HealthCheck endpoints resolve in swagger for each present version
HealthCheck endpoint is responsive at any agnostic version, or versions not explicitly in use by the application (example/api/v999/healthcheck)
Here is my current structure:
In Swagger this appears as:
However, after the upgrade I can no longer target the healthcheck endpoint agnostically. For any version beyond what's in specific use by my application controllers I will receive a 404 not found.
This is an issue for service infrastructure that targets a v1/healthcheck on an application that no longer has v1 controllers.
I was able to overcome this behavior by modifying my route to {version:int}:
but this is undesirable as it breaks my swagger UI - expecting a parameter:
For reference here is how my application versioning is configured:
Where there any breaking changes around the ApiVersionNeutral attribute?
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
@commonsensesoftware -- I see you commented on a similar issue #1093 do you think you have any insight to this?
The text was updated successfully, but these errors were encountered: