OpenAPITools / OpenAPITools/openapi-generator

[REQ][rust] Use relative paths in generated code

Open
#20,740 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

The rust generator should support dropping the generated code into an arbitrary path in the crate. Currently, each generated file refers to the absolute path crate::models, forcing the use of hacks like search and replace if the generated could should be in crate::api::models, for example.

Describe the solution you'd like

Rust doesn't make this obvious but we can import the parent without the absolute path using:

use super::super::models;

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 at the Rust generator entry point and trace how generated files emit imports of crate::models; inspect the relevant generation logic or templates. Done means generated code can be placed under an arbitrary crate path such as crate::api::models without search-and-replace, with coverage verifying the relative imports.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.