Skip to content
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 attribute fails to match query parameters to raw identifier function arguments #117

Closed
alexjpayne opened this issue Oct 11, 2022 · 3 comments

Comments

@alexjpayne
Copy link

alexjpayne commented Oct 11, 2022

When creating a route, if I use a query parameter with a name that corresponds to a Rust keyword (e.g. type), the openapi attribute macro fails to match the query parameter to the function argument. Presumably this is because the function argument has to be prepended with r# in order for rust to consider it as a raw identifier instead of the type keyword, and then the macro cant tell that type == r#type.

It appears this was an issue for rocket that was resolved a few years ago rwf2/Rocket#881. I'm certain that this is issue is with the openapi attribute, as if I use #[openapi(skip)] then everything works as expected.

I've created a branch with a new example demonstrating the problem: https://github.com/alexjpayne/okapi/tree/openapi_fails_to_match_raw_identifier_to_query_param

See: https://github.com/alexjpayne/okapi/blob/openapi_fails_to_match_raw_identifier_to_query_param/examples/raw_indentifiers/src/main.rs

@ralpha ralpha closed this as completed in 69f3dc4 May 29, 2023
@ralpha
Copy link
Collaborator

ralpha commented May 29, 2023

I used your example as a new test and fixed this issue.
So this should work with the next version of this crate.
Thanks for creating an issue for this.

@alexjpayne
Copy link
Author

Thank you for fixing this, I appreciate it 🙂

@ralpha
Copy link
Collaborator

ralpha commented May 30, 2023

No problem :) The new release was created the same day.
So hope it works now, let me know if you find any other problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants