OpenAPITools / OpenAPITools/openapi-generator
[BUG] [rust] Field access is broken
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
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
For paths composed of fields of a structure, the generated Rust code does not compile:
error: invalid format string: field access isn't supported
--> src/apis/amizone_service_api.rs:174:64
|
174 | ..."{}/api/v1/class_schedule/{date.year}/{date.month}/{date.day}", local_var_configuration.base_p...
| ^^^^^^^^^ not supported in format string
openapi-generator version
6.5.0
OpenAPI declaration file content or url
Generation Details
openapi-generator-cli generate -g rust -o rust -i amizone.proto
Steps to reproduce
- Generate client code.
cargo buildto try building it.
Related issues/PRs
Suggest a fix
As suggested by the rust compiler, use positional arguments instead of interpolation for fields. Less readable but works just as well for field access.
/cc @farcaller
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust generator entry point used by openapi-generator-cli generate -g rust, using the linked amizone.proto as the reproduction input. Generate the client and run cargo build to inspect the field-access format string failure. Done means the generated Rust client compiles successfully for this input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100