OpenAPITools / OpenAPITools/openapi-generator

[rust-client] Ability to specify path of output

Open
#20,963 0 comments 0 reactions 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

Currently output is always generated as src/{apis,models} as done by:

https://github.com/OpenAPITools/openapi-generator/blob/16552755bffa4f1a4d7e1afc67cf7e97dc1cd1f4/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java#L85-L86

In our case we run with a very limited generator (we only want the models).

.openapi-generator-ignore:

**
.openapi-generator/*
!src/models/*.rs

What we end up doing is a little odd:

mkdir -p generated/rust
rm -rf ./src/api/models
docker run --user $(id -u) --rm -v "${PWD}:/local" -w /local/generated/rust openapitools/openapi-generator-cli:v7.12.0 generate -i /local/api/kiburi.v0.yml -g rust --config /local/.openapi-generator/rust/config.yaml
mv ./generated/rust/src/models ./src/api/model

Ideally it would be nicer if we could directly write the models etc to a subfolder inside our rust crate and not require manual modification.

I can imagine an additionalProperty: asModule: true or something like this.

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 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java at the referenced lines, then inspect the Rust generator configuration and the docker generate command shown in the issue. Define how an additional property or equivalent configuration should select an output subfolder, and verify that models can be generated directly into the Rust crate without the manual move.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.