Skip to content

[rust] Reserved words should be prefixed with raw identifiers (r#) #13171

@jacob-pro

Description

@jacob-pro
Description

In Rust the correct way to escape a reserved word is to use raw identifiers:

https://doc.rust-lang.org/book/appendix-01-keywords.html#raw-identifiers

Currently they are being prefixed with _ which in Rust is used to indicate an unused identifier:

https://doc.rust-lang.org/stable/nightly-rustc/rustc_lint_defs/builtin/static.UNUSED_VARIABLES.html#explanation

openapi-generator version

All versions as far as I am aware:

https://github.com/OpenAPITools/openapi-generator/blob/7.0.x/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java#L418

Related issues/PRs

A similar issue was created for Rust Server (not Rust client), which correctly identified the issue with using _ but applied the prefix of param_ instead:

#5455

Suggest a fix/enhancement

I will create a PR to fix this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions