-
Notifications
You must be signed in to change notification settings - Fork 708
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
OpenAPI not working with version interleaving within single controller #1025
Comments
Indeed this is an issue and I've been able to reproduce the conditions. Interestingly, it appears that this behavior has always existed or, at least, certainly for a long time, but has not been reported. Version interleaving with OpenAPI is meant to be supported and it partially is. There is clearly a missing edge case where an overlapping API path will produce a duplicate entry when an action is implicitly matched and is not discarded if an explicitly matched action supersedes it. This is a 🐞 and I've come up with a remedy. As you noted, this behavior does not affect routing, which uses the same implicit matching rules, but is implemented completely differently. The The default behavior for the documented The immediate workaround is to explicitly use |
Thanks a lot for the quick fix! Haven't been able to take it for a spin yet (been busy visiting a conference this week), but I'm sure I will like it :). Thanks again, and keep up the good work! |
Explicit mappings will now supersede implicit mappings so that problem is fixed.
Enjoy the conference. 😉 |
Is there an existing issue for this?
Describe the bug
Hi,
Starting note: this issue describes 2 bugs (or at least unexpected behaviors) because I can imagine that they are related. If I need to split them up into separate issues, just let me know.
It appears that generating OpenAPI specifications breaks when doing version interleaving within a single controller, where not all actions are explicitly mapped. So a controller decorated with multiple ApiVersion attributes, and two actions on the same path where only one of these actions is decorated with MapToApiVersion, will break the OpenAPI spec for the explicitly mapped version. Actually calling the actions works as expected; it's just the OpenAPI generation that breaks.
Also, is it expected that the OpenAPI specs do no respect the ApiVersionSelector? If I use LowestImplementedApiVersionSelector, I can omit the api-version (which is expected), but the generated OpenAPI spec indicates that api-version is required.
Expected Behavior
With regards to the breaking API spec: I would expect that interleaving versions within a single controller, when done according to the wiki, does not break OpenAPI. A valid outcome would be that the wiki needs to be updated to reflect that implicit version interleaving is not compatible with OpenAPI.
With regards to OpenAPI and the ApiVersionSelector: I would expect that OpenAPI does not require a parameter that is not, in fact, required.
Steps To Reproduce
With regards to the breaking API spec: adding the controller from the samples (see below) to the OpenApiExample, breaks the OpenAPI spec for version 3.0.
With regards to OpenAPI and the ApiVersionSelector: given a project where the DefaultApiVersion is not touched (so is 1.0); AssumeDefaultVersionWhenUnspecified = true; and the ApiVersionSelector is set to LowestImplementedApiVersionSelector , what I observe is
Exceptions (if any)
Exception for the broken OpenAPI spec:
.NET Version
7.0.400
Anything else?
No response
The text was updated successfully, but these errors were encountered: