-
Notifications
You must be signed in to change notification settings - Fork 712
wrong parameter type in api document with [FromODataUri] attribute #693
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
Comments
I only partially understand your scenario or setup. I don't know that
Endpoint Routing is the default routing mechanism in ASP.NET Core (since 2.2). OData finally supports it (as of 7.4). All examples and defaults now use Endpoint Routing as well. This may be hanging you up because the runtime behavior will be different. If you want to go back to the legacy routing conventions, you can. You need only configuration the MVC options with: OData by itself does not have formal support for the API Explorer and it will not work with the default ASP.NET Core API Explorer. API Versioning does not consider or use non-OData attributes such I need more information before I can investigate. |
The behavior with [ApiController] is right in odata api versioning 5.0.0 . I can't make [ApiController] recognize parameters in odata route template in a none-versioning environment. In other words, behavior of odata api versioning 4.1.1 is wrong. (In version 4.1.1, parameters in odata route template can't be bound with the usage of [ApiController] when the application start. However, requesting the api document causes some side effects which change the way controllers work. After the request to api document, parameters in odata route template can be bound. I set the debug option to open swagger document page when the app start, which hides the real problem.) As you said, [FromODataUri] should do nothing to the api explorer, so there is no need to consider it specially. But in fact, [FromODataUri] causes wrong api document. Like this: This screenshot is taken from AspNetCore SwaggerODataSample project. |
I am also running into this issue - when attempting to use FromODataUri attribute, it is assuming a query parameter when displayed in Swagger. |
I'm going to mark this as a bug because it doesn't do what you expect. Honestly, the OData implementation is not meant to support OpenAPI/Swagger. There continues to be very shallow support for what OData would really need. This particular issue derives from I think have a solution for it. In the meantime, your options are:
|
Uh oh!
There was an error while loading. Please reload this page.
Run the newest aspnetcore odata swagger sample project directly. all parameters decorated with [FromODataUri] are marked with 'query' (in query string) but not 'path' (in url) in the api document. path parameters decorated with [FromRoute] attribute or no attribute are marked as 'path' correctly.
add [ApiController] (i use this to make auto 400 response and some analyzers use this to realize a controller is not a view controller) and [Route("")] (which can't work without api versioning because multiple actions match same route; it seems that api versioning make it be ignored) to odatacontroller, path parameters in odata route template decorated with no attribute can't be recognized by the middleware , instead they are considered same as decorated with [FromQuery]. This is a default behavior of [ApiController] if the middleware can not find the parameter in route template. The problem is that the middleware should find these parameters but not. In odata api versioning 4.1.1, there is no such problem. This might be caused by same underlying mistake with problem i mentioned in #692 (comment)The text was updated successfully, but these errors were encountered: