OpenAPITools / OpenAPITools/openapi-generator

[BUG][Rust] Invalid Rust code generated

Open
#12,464 1 comment 4 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

https://api.inaturalist.org/v1/swagger.json

error[E0599]: the method `join` exists for struct `Vec<i32>`, but its trait bounds were not satisfied
    --> src/apis/identifications_api.rs:1260:105
     |
1260 |     let local_var_uri_str = format!("{}/identifications/{id}", local_var_configuration.base_path, id=id.join(",").as_ref());
     |                                                                                                         ^^^^ method cannot be called on `Vec<i32>` due to unsatisfied trait bounds
     |
     = note: the following trait bounds were not satisfied:
             `[i32]: Join<_>`

error[E0599]: the method `join` exists for struct `Vec<i32>`, but its trait bounds were not satisfied
    --> src/apis/observations_api.rs:2394:102
     |
2394 |     let local_var_uri_str = format!("{}/observations/{id}", local_var_configuration.base_path, id=id.join(",").as_ref());
     |                                                                                                      ^^^^ method cannot be called on `Vec<i32>` due to unsatisfied trait bounds
     |
     = note: the following trait bounds were not satisfied:
             `[i32]: Join<_>`

warning: variable does not need to be mutable
  --> src/apis/photos_api.rs:57:9
   |
57 |     let mut local_var_form = reqwest::multipart::Form::new();
   |         ----^^^^^^^^^^^^^^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

error[E0283]: type annotations needed
   --> src/apis/places_api.rs:126:106
    |
126 |     let local_var_uri_str = format!("{}/places/{id}", local_var_configuration.base_path, id=id.join(",").as_ref());
    |                                                                                             -------------^^^^^^--
    |                                                                                             |            |
    |                                                                                             |            cannot infer type for type parameter `T` declared on the trait `AsRef`
    |                                                                                             this method call resolves to `&T`
    |
    = note: multiple `impl`s satisfying `std::string::String: AsRef<_>` found in the following crates: `alloc`, `std`:
            - impl AsRef<OsStr> for std::string::String;
            - impl AsRef<Path> for std::string::String;
            - impl AsRef<[u8]> for std::string::String;
            - impl AsRef<str> for std::string::String;

error[E0283]: type annotations needed
   --> src/apis/projects_api.rs:520:108
    |
520 |     let local_var_uri_str = format!("{}/projects/{id}", local_var_configuration.base_path, id=id.join(",").as_ref());
    |                                                                                               -------------^^^^^^--
    |                                                                                               |            |
    |                                                                                               |            cannot infer type for type parameter `T` declared on the trait `AsRef`
    |                                                                                               this method call resolves to `&T`
    |
    = note: multiple `impl`s satisfying `std::string::String: AsRef<_>` found in the following crates: `alloc`, `std`:
            - impl AsRef<OsStr> for std::string::String;
            - impl AsRef<Path> for std::string::String;
            - impl AsRef<[u8]> for std::string::String;
            - impl AsRef<str> for std::string::String;

error[E0599]: the method `join` exists for struct `Vec<i32>`, but its trait bounds were not satisfied
   --> src/apis/taxa_api.rs:274:94
    |
274 |     let local_var_uri_str = format!("{}/taxa/{id}", local_var_configuration.base_path, id=id.join(",").as_ref());
    |                                                                                              ^^^^ method cannot be called on `Vec<i32>` due to unsatisfied trait bounds
    |
    = note: the following trait bounds were not satisfied:
            `[i32]: Join<_>`

The problem seems to be this line:

https://github.com/OpenAPITools/openapi-generator/blob/21f649e0873f29571b9bb9b69c7a8e962e3954d0/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache#L99

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 template at modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache, especially line 99, then generate a client from the linked Swagger document. Compare the affected identifications, observations, places, projects, and taxa API calls with the compiler errors. Done means the generated Rust client compiles without these join and type-inference errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.