Skip to content

[BUG] [rust-client] Unable to generate rust client for docker api #2532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
5 of 6 tasks
pgrinaway opened this issue Mar 28, 2019 · 2 comments
Open
5 of 6 tasks

[BUG] [rust-client] Unable to generate rust client for docker api #2532

pgrinaway opened this issue Mar 28, 2019 · 2 comments

Comments

@pgrinaway
Copy link

pgrinaway commented Mar 28, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

openapi-generator successfully generates an output for the Docker engine v1.39 spec, albeit with a number of warnings such as

[main] WARN  o.o.codegen.DefaultCodegen - codegenModel is null. Default to UNKNOWN_BASE_TYPE

...

[main] WARN  o.o.c.examples.ExampleGenerator - example value (array/primitive) not handled at the moment: [{ID=ktnbjxoalbkvbvedmg1urrz8h, Version={Index=11}, CreatedAt=2016-11-05T01:20:17.327670065Z, UpdatedAt=2016-11-05T01:20:17.327670065Z, Spec={Name=server.conf}}]

Full output here.

Upon attempting to compile the resulting code, there are numerous errors from the Rust compiler such as:

error[E0412]: cannot find type `Value` in this scope
  --> src/apis/container_api.rs:52:76
   |
52 |     fn container_stats(&self, id: &str, stream: bool) -> Box<Future<Item = Value, Error = Error<serde_json::Value>>>;

...

error[E0277]: the trait bound `models::File: serde::Serialize` is not satisfied
  --> src/apis/plugin_api.rs:58:14
   |
58 |             .with_body_param(body)
   |              ^^^^^^^^^^^^^^^ the trait `serde::Serialize` is not implemented for `models::File`

error: aborting due to 25 previous errors

Full compiler output here.

openapi-generator version
(base) Patricks-MBP:test1 pgrinaway$ openapi-generator version
3.3.4
OpenAPI declaration file content or url

The OpenAPI declaration can be found here

Command line used for generation

I ran:

openapi-generator generate -i https://docs.docker.com/engine/api/v1.39/swagger.yaml -g rust -o rust_client/

Using openapi-generator version 3.3.4 on Mac OS X Mojave 10.14.3.
Cargo version cargo 1.32.0 (8610973aa 2019-01-02)

Steps to reproduce

Generate the rust code:

mkdir rust_docker && openapi-generator generate -i https://docs.docker.com/engine/api/v1.39/swagger.yaml -g rust -o rust_docker/

Attempt to compile:

cd rust_docker && cargo build
Related issues/PRs

I'm not sure if #2527 is related, since it is trying to also generate a client for this API. Possibly PR #2244 is related, but again I am unsure.

Suggest a fix

I am relatively new to rust, but manually inserting a use serde_json::Value; in the generated code did make the error about the Value go away. However, I'm not quite sure how to fix the other errors.

@auto-labeler
Copy link

auto-labeler bot commented Mar 28, 2019

👍 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.

@ximon18
Copy link

ximon18 commented Jun 15, 2020

I'm seeing this issue with OpenAPI generator v4.3.1 and v5.0.0-SNAPSHOT. I tried with both v1.36 and v1.40 of the Docker API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants