Closed cfauchere closed 5 months ago
This is a rare edge case, but it is the expected behavior.
The $metadata
endpoint, like the API Explorer, collates API versions from all OData controllers. If all of the APIs are version-neutral, then there is nothing to collate. This is a very strange use case. There's no reason for all APIs to be version-neutral. What's the point of using API Versioning if everything is neutral? Version-neutral doesn't mean unversioned. A version-neutral API should not, and will not, respond to an API version that doesn't exist. An API, version-neutral or not, shouldn't respond to ?api-version=42.0
if it doesn't exist.
If you configure ApiVersioningOptions.AssumeDefaultVersionWhenUnspecified = true
, then things might work. I seem to recall that if no versions are found, ApiVersioningOptions.DefaultApiVersion
is used as a fallback. I'm not sure if that changes anything for you. It's not something I believe I've tried or tested for. It's very strange use case.
Unless you only had one API, it's your first API, and it just happens to be version-neutral, I'm not sure why you'd want to do this. Can you explain your use case a bit more? I suspect there is a better way to do what you are trying to achieve.
There wasn't any additional follow-up or push-back. This behavior is expected and is an unfortunate limitation and edge case that is effectively nonsensical in a real application. I could document this as a known limitation if you feel it is warranted. It's such a bizarre use case, I never thought anyone would actually hit it.
This behavior is expected albeit not as obvious as one might expect. The discussion appears to have gone idle and I don't think there's any more to do. If there, feel free to reopen the issue.
When all API controllers are decorated with the ApiVersionNeutralAttribute, the odata/$metadata always return 404. Removing the attribute on a single controller makes the issue go away. WebApplication1.zip