okapi icon indicating copy to clipboard operation
okapi copied to clipboard

OpenAPI attribute fails to match query parameters to raw identifier function arguments

Open alexjpayne opened this issue 3 years ago • 0 comments

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 https://github.com/SergioBenitez/Rocket/issues/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

alexjpayne avatar Oct 11 '22 15:10 alexjpayne