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

[Rust][client] Partly fix bug #16974 - add missing imports #17503

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

j-szulc
Copy link
Contributor

@j-szulc j-szulc commented Dec 30, 2023

Note: this PR is not complete as there are issues I cannot do on my own (see below), hence draft PR.

It partly fixes the related issue #16974.
This PR simply adds a line to the top of *_api.rs importing the models used as arguments of the endpoint functions.

The issue is that:

  1. If a model is used multiple times, it's being imported multiple times, which causes an error,
  2. There are warnings that some imports are unused (maybe goes away after fixing 1. above)

As Mustache is a logic-less template engine, to filter out a unique list of models requires delving into the enormous Java codebase of this project, which I can't do.

Mentioning technical committee per PR checklist: @jacob-pro

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.1.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Comment on lines +5 to +6
use crate::apis::ResponseContent;{{#operations}}{{#operation}}{{#allParams}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}
use crate::models::{{{dataType}}};{{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{/allParams}}{{/operation}}{{/operations}}
Copy link
Contributor

@DDtKey DDtKey Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue not imports itself, clients use clarified path to models, i.e models::MyStruct. Usually there is no need for explicit imports here.

This change creates a lot of extra imports, for example affected apis by this PR - worked fine even before, but check/clippy will highlight that there are extra clarified paths.
Moreover imports not unique, eg:

I think the issue is this condition: {{#isBodyParam}}models::{{/isBodyParam}} (e.g https://github.com/OpenAPITools/openapi-generator/blob/a8efb8eea8a8136311db2fa4dfea6df39d1c3d4a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache#L93C483-L93C523)

So we have 2 questions:

  1. why it's not true for these models?
  2. for hyper we don't use this condition and it seems to work

UPD: I've submitted this PR: #17968

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

Successfully merging this pull request may close these issues.

2 participants