swagger-api / swagger-api/swagger-codegen

[Rust] Lots of unused import warnings

Open
#8,170 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When building Rust APIs there are a lot of warnings about unused imports. They are noisy and clutter up the build process.

Swagger-codegen version

Any recent.

Swagger declaration file content or url

I have been working from https://esi.evetech.net/latest/swagger.json?datasource=tranquility .

Command line used for generation

Any normal -l rust command line.

Steps to reproduce

Generate the Rust API from above. Run cargo build. Notice the warnings.

Related issues/PRs

None noted.

Suggest a fix/enhancement

The easiest fix, which seems completely harmless in this case, is to stick #![allow(unused)] at the start of the appropriate files: at least api.mustache and model_mod.mustache. Probably also get rid of the unused import of HashMap in model_mod.mustache.

One could try to be more selective about which imports are generated, but it hardly seems worth it.

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 templates api.mustache and model_mod.mustache, then reproduce the issue by generating an API with the provided Swagger declaration and running cargo build. Check the generated output for unused import warnings, including the HashMap import in model_mod.mustache. Done means the generated Rust API builds without the reported unused-import warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.