swagger-api / swagger-api/swagger-codegen
In rust code generation trait objects should contain an explicit `dyn`
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Q&A (please complete the following information)
- OS: Fedora 39
- Browser: Firefox
- Version:
- Method of installation: docker
- Swagger-Editor version: [e.g. 3.10.0]
- Swagger/OpenAPI version: [Swagger 2.0, ]
Content & configuration
I will not share our yaml, as it can contain confidential information I am not allowed to share.
Describe the bug you're encountering
I generated a rust client and it contains a lot of warnings, it shows like this:
warning: trait objects without an explicit `dyn` are deprecated
--> src/apis/client.rs:197:31
|
197 | pub fn tools_api(&self) -> &::apis::ToolsApi{
| ^^^^^^^^^^^^^^^^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn`
|
197 | pub fn tools_api(&self) -> &dyn (::apis::ToolsApi){
| +++++ +
To reproduce...
Steps to reproduce the behavior:
- Make a yaml with a circular reference within its models
- Generate a rust client
- Try to build
- See compiler error
Expected behavior
I expect the rust client generator to generate working code.
Additional context or thoughts
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
Reproduce the issue with an OpenAPI YAML containing a circular model reference, generate a Rust client, and inspect the generated src/apis/client.rs around the tools_api method. Trace that output back to the Rust code-generation template. Done means the generated client builds under Rust 2021 without the deprecated trait-object warning or resulting error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100