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.23k stars 6.43k forks source link

[REQ][Rust Client] Error type should implement std::error:Error #6651

Open HenningHolmDE opened 4 years ago

HenningHolmDE commented 4 years ago

Is your feature request related to a problem? Please describe.

As recommended by the Rust API Guidelines, custom error types used in a Result<T, E> should implement the std::error::Error and std::fmt::Display traits, which is currently not the case.

https://rust-lang.github.io/api-guidelines/interoperability.html#c-good-err: An error type is any type E used in a Result<T, E> returned by any public function of your crate. Error types should always implement the std::error::Error trait which is the mechanism by which error handling libraries like error-chain abstract over different types of errors, and which allows the error to be used as the source() of another error. [...]

Describe the solution you'd like

Implementing the corrensponding traits in reqwest\api_mod.mustache would improve error handling when using the generated API.

Describe alternatives you've considered

To solve this for my API client, I implemented the traits myself using a custom template. I would be happy to provide a PR for this, if the change is desired by the community.

Additional context

I am currently using SNAPSHOT version 5.0.0-20200613.071037-272.

plasticartsshow commented 1 year ago

To solve this for my API client, I implemented the traits myself using a custom template. I would be happy to provide a PR for this, if the change is desired by the community.

This is a great idea.