swagger-api / swagger-api/swagger-codegen
rust-server generated code does not compile
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The code generated from our swagger file fails to compile with multiple errors.
Swagger-codegen version
Tried with current stable release and with recent nightly (swagger-codegen-cli-2.4.0-20180511.013033-251.jar)
Swagger declaration file content or url
https://github.com/aeternity/epoch/blob/master/config/swagger.yaml
Command line used for generation
java -jar ~/Downloads/swagger-codegen-cli-2.4.0-20180511.013033-251.jar generate -i ../aeternity/src/epoch/config/swagger.yaml -l rust-server
Steps to reproduce
java -jar ~/Downloads/swagger-codegen-cli-2.4.0-20180511.013033-251.jar generate -i ../aeternity/src/epoch/config/swagger.yaml -l rust-server
cargo check
fails with multiple errors like
error[E0201]: duplicate definitions with name `get_tx`:
--> src/client/mod.rs:14218:5
|
6838 | / fn get_tx(&self, param_tx_hash: String, param_tx_encoding: Option<String>, context: &C) -> Box<Future<Item=GetTxResponse, Error=ApiError>> {
6839 | |
6840 | | // Query parameters
6841 | | let query_tx_encoding = param_tx_encoding.map_or_else(String::new, |query| format!("tx_encoding={tx_encoding}&", tx_encoding=query.to_string()));
... |
6949 | |
6950 | | }
| |_____- previous definition of `get_tx` here
...
14218 | / fn get_tx(&self, param_tx_hash: String, param_tx_encoding: Option<String>, context: &C) -> Box<Future<Item=GetTxResponse, Error=ApiError>> {
14219 | |
14220 | | // Query parameters
14221 | | let query_tx_encoding = param_tx_encoding.map_or_else(String::new, |query| format!("tx_encoding={tx_encoding}&", tx_encoding=query.to_string()));
... |
14329 | |
14330 | | }
| |_____^ duplicate definition
error[E0201]: duplicate definitions with name `get_txs`:
--> src/client/mod.rs:14332:5
|
6952 | / fn get_txs(&self, context: &C) -> Box<Future<Item=GetTxsResponse, Error=ApiError>> {
6953 | |
6954 | |
6955 | | let uri = format!(
... |
7019 | |
7020 | | }
| |_____- previous definition of `get_txs` here
...
14332 | / fn get_txs(&self, context: &C) -> Box<Future<Item=GetTxsResponse, Error=ApiError>> {
14333 | |
14334 | |
14335 | | let uri = format!(
... |
14399 | |
14400 | | }
| |_____^ duplicate definition
error: aborting due to 889 previous errors
Related issues/PRs
Suggest a fix/enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked swagger.yaml and reproduce the issue using the documented swagger-codegen CLI command with the rust-server generator. Run cargo check on the generated project and trace the duplicate get_tx/get_txs definitions; done means the generated Rust code compiles without the reported errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100