Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Rust] Invalid Rust code generated #12464

Open
frewsxcv opened this issue May 26, 2022 · 1 comment
Open

[BUG][Rust] Invalid Rust code generated #12464

frewsxcv opened this issue May 26, 2022 · 1 comment

Comments

@frewsxcv
Copy link

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:

let local_var_uri_str = format!("{}{{{path}}}", local_var_configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{#isString}}){{/isString}}{{/pathParams}});

@manzaltu
Copy link

manzaltu commented Sep 15, 2024

Also happens with https://api.crossref.org/swagger-docs.

Compiling crossref-api v1.0.0 (crossref-api)
error[E0283]: type annotations needed
  --> crossref-api/src/apis/journals_api.rs:90:114
   |
90 |     let local_var_uri_str = format!("{}/journals/{issn}", local_var_configuration.base_path, issn=issn.join(",").as_ref());
   |                                                                                                                  ^^^^^^
   |
   = 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;
help: try using a fully qualified path to specify the expected types
   |
90 |     let local_var_uri_str = format!("{}/journals/{issn}", local_var_configuration.base_path, issn=<std::string::String as AsRef<T>>::as_ref(&issn.join(",")));
   |                                                                                                   +++++++++++++++++++++++++++++++++++++++++++              ~

error[E0283]: type annotations needed
   --> crossref-api/src/apis/journals_api.rs:118:120
    |
118 |     let local_var_uri_str = format!("{}/journals/{issn}/works", local_var_configuration.base_path, issn=issn.join(",").as_ref());
    |                                                                                                                        ^^^^^^
    |
    = 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;
help: try using a fully qualified path to specify the expected types
    |
118 |     let local_var_uri_str = format!("{}/journals/{issn}/works", local_var_configuration.base_path, issn=<std::string::String as AsRef<T>>::as_ref(&issn.join(",")));
    |                                                                                                         +++++++++++++++++++++++++++++++++++++++++++              ~

For more information about this error, try `rustc --explain E0283`.
error: could not compile `crossref-api` (lib) due to 2 previous errors

rust-compilation exited abnormally with code 101 at Sun Sep 15 18:01:13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants