[BUG][Rust] Request trait library does not compile with keyword parameters #20329
Closed
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Function parameters are properly escaped with r#
but with the new reqwest-trait client we introduced lifetime parameters that reused to the parameter name.
#
is not valid in lifetime names.
Error
115 | async fn find_pets_by_status<'r#type>(&self, r#type: Option<&'r#type str>) -> Result<Vec<models::Pet>, Error<FindPetsByStatusError>> {
| ^ expected one of `,`, `:`, or `>`
openapi-generator version
build from source Git Hash cc40f40
OpenAPI declaration file content or url
# ...
/pet/findByStatus:
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
parameters:
- name: type # <------- This is a Rust keyword
in: query
description: Status values that need to be considered for filter
required: false
explode: true
schema:
type: string
default: available
enum:
- available
- pending
- sold
# ...
Generation Details
generatorName: rust
library: reqwest-trait
additionalProperties:
supportMiddleware: true
preferUnsignedInt: true
topLevelApiClient: true
useBonBuilder: true
mockall: true
Steps to reproduce
- Create an openapi spec with query param with the name of any Rust keyword
- Generate the client with the config above
- Run
cargo build
Related issues/PRs
Suggest a fix
This can be fixed by simply replacing the r#
with a r_
as that is a valid lifetime name.