OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.87k stars 6.59k forks source link

[BUG][Rust server] `Can't find ``client`` example, specify example.path` when running server stub #9023

Open kubajal opened 3 years ago

kubajal commented 3 years ago

Bug Report Checklist

Description

I'm developing a small project here: https://github.com/kubajal/minimax-in-rust I cannot run code generated by openapi-generator-cli v5.0.1 through cargo run --example server in Docker image rust:1.50 . I get the following error:

root@67eadc0267a7:/rust-app# cargo run --example server
error: failed to parse manifest at `/rust-app/Cargo.toml`

Caused by:
  can't find `client` example, specify example.path

I'd expect this to succeed as that is the step described in the README.md generated by npx @openapitools/openapi-generator-cli generate -i swagger.yml -g rust-server.

openapi-generator version

v5.0.1 I downloaded it through https://openapi-generator.tech/docs/installation/.

OpenAPI declaration file content or url

https://github.com/kubajal/minimax-in-rust/blob/main/swagger.yml

Generation Details

I just used npx @openapitools/openapi-generator-cli generate -i swagger.yml -g rust-server.

Steps to reproduce
git clone https://github.com/kubajal/minimax-in-rust.git
cd minimax-in-rust
docker build -t rust-app
docker run -it rust-app
# in the container
cd /rust-app
cargo run --example server
Related issues/PRs

None that I found.

Suggest a fix

I have no idea. I am a beginner in Rust.

auto-labeler[bot] commented 3 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

wing328 commented 3 years ago

cc @richardwhiuk

richardwhiuk commented 3 years ago

Did you generate with an older version, and then generate with a newer version over the top?

The latest generator doesn't produce examples/client.rs, or examples/server.rs, but these exist in your generated code.

This was changed in https://github.com/OpenAPITools/openapi-generator/pull/5405 where we updated the generator to match Rust's standard for multi-file examples, where we have examples/client/main.rs and examples/server/main.rs.