-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Open
Labels
Description
Description
I have written a simple, sample API, and rust-server generates code which doesn't compile.
Full cargo build output here, but there are three problems:
- models::models::models::TYPE used instead of models::TYPE, e.g.
error[E0603]: module `models` is private
--> src/lib.rs:77:35
|
77 | fn a_post(&self, arg: models::models::models::Arg) -> Box<Future<Item=APostResponse, Error=ApiError>>;
- wrong variable used to log parameter e.g.
error[E0277]: `()` doesn't implement `std::fmt::Display`
--> src/server/mod.rs:210:173
|
210 | Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter arg: {}", e)))),
In this case , e)
should be , param_arg)
- invalid FromStr implementation e.g.
error[E0308]: match arms have incompatible types
--> src/models.rs:42:9
|
42 | / match s {
43 | | "0" => Ok(Arg::_0),
| | ----------- match arm with an incompatible type
44 | | "1" => Ok(Arg::_1),
45 | | "2" => Ok(Arg::_2),
46 | | _ => Err(()),
47 | | }
| |_________^ expected enum `std::result::Result`, found struct `models::Ok`
|
= note: expected type `std::result::Result<models::Arg, ()>`
found type `models::Ok`
This might be a little harsh! The problem is that Ok
here is models::Ok
not Result::Ok
.
Commit fixing the compilation errors here.
There are also similar errors with the client and server examples, plus also an extraneous use swagger::auth::Authorization;
causing the server example to fail to compile:
error: unused import: `swagger::auth::Authorization`
--> examples/server_lib/mod.rs:16:5
|
16 | use swagger::auth::Authorization;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D unused-imports` implied by `-D warnings`
Fixes for the client and server examples are in this commit.
openapi-generator version
4.0.0-SNAPSHOT
Using container openapitools/openapi-generator-cli:latest
OpenAPI declaration file content or url
Command line used for generation
docker run --rm \
-v ~/openapi-generator-rust-server-test/openapi_client:/local \
openapitools/openapi-generator-cli \
generate \
-g rust-server \
-i /local/openapi.yaml \
-o /local
Steps to reproduce
cd ~
git clone https://github.com/piersfinlayson/openapi-generator-rust-server-test
cd openapi-generator-rust-server-test
docker pull openapitools/openapi-generator-cli
docker run --rm \
-v ~/openapi-generator-rust-server-test/openapi_client:/local \
openapitools/openapi-generator-cli \
generate \
-g rust-server \
-i /local/openapi.yaml \
-o /local
cd openapi_client
cargo build
cargo build --example client
cargo build --example server
Related issues/PRs
None that I can see
Suggest a fix
See above