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] Bad module import generated with Option types #20141

Open
4 of 6 tasks
mgalliou opened this issue Nov 20, 2024 · 0 comments
Open
4 of 6 tasks

[BUG][Rust] Bad module import generated with Option types #20141

mgalliou opened this issue Nov 20, 2024 · 0 comments

Comments

@mgalliou
Copy link

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

Hi,

When generating rust client with default configuration, the generated code contains compilation errors related to models module importation inside Option types (models::models:: instead of models::):

error[E0433]: failed to resolve: could not find `models` in `models`
   --> src/apis/accounts_api.rs:101:157
    |
101 | ...configuration::Configuration, account: &str, r#type: Option<models::models::AchievementType>, completed: Option<bool>, page: Option<i32>, size: Option<i32>) -> Result<models::Data...
    |                                                                        ^^^^^^ could not find `models` in `models`
    |
help: consider importing this module
    |
12  + use crate::models;
    |
help: if you import `models`, refer to it directly
    |
101 - pub async fn get_account_achievements_accounts_account_achievements_get(configuration: &configuration::Configuration, account: &str, r#type: Option<models::models::AchievementType>, completed: Option<bool>, page: Option<i32>, size: Option<i32>) -> Result<models::DataPageAccountAchievementSchema, Error<GetAccountAchievementsAccountsAccountAchievementsGetError>> {
101 + pub async fn get_account_achievements_accounts_account_achievements_get(configuration: &configuration::Configuration, account: &str, r#type: Option<models::AchievementType>, completed: Option<bool>, page: Option<i32>, size: Option<i32>) -> Result<models::DataPageAccountAchievementSchema, Error<GetAccountAchievementsAccountsAccountAchievementsGetError>> {
    |

When generating using master (18b01ca), I also get following kind of error:

error[E0282]: type annotations needed
   --> src/apis/accounts_api.rs:110:87
    |
110 |         local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
    | 

openapi-generator version

7.10.0

OpenAPI declaration file content or url

https://api.artifactsmmo.com/openapi.json

Generation Details

 docker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli generate \
             -i https://api.artifactsmmo.com/openapi.json \
             -g rust \
             -o /local/out/rust

Steps to reproduce

Build the generated crate using cargo build.

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

1 participant