OpenAPITools / OpenAPITools/openapi-generator

[BUG] [rust] Field access is broken

Open
#15,168 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

https://github.com/ditsuke/go-amizone/blob/1f6779de9d19268d069255a5465187ac429db839/server/proto/v1/amizone.proto

Generation Details

openapi-generator-cli generate -g rust -o rust -i amizone.proto

Steps to reproduce
  1. Generate client code.
  2. cargo build to 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.