Skip to content
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

[Rust] Use unimplemented! or compile_error! instead of TODO #16167

Open
tastenbier opened this issue Jul 23, 2023 · 0 comments
Open

[Rust] Use unimplemented! or compile_error! instead of TODO #16167

tastenbier opened this issue Jul 23, 2023 · 0 comments

Comments

@tastenbier
Copy link

Description

The Rust generator currently does not support all OpenAPI features. In case of an unsupported feature, instead of an implementation, a TODO comment is generated. One example would be file upload for clients if you enable supportAsync (which is enabled by default).

// TODO: support file upload for '{{{baseName}}}' parameter


There is nothing wrong with that. Supporting all features takes time. However, I would suggest to replace or complement this TODO comment with either an unimplemented! or compile_error! macro call.

Rationale:
This would improve the user (i.e. developer) experience. Because either the code would not compile (compile_error!), telling the developer exactly where something needs to be done. Or the code would fail in a more obvious way during runtime (unimplemented!), instead of just silently doing nothing.

Currently, you can generate a client, the code compiles, you can run it, and everything seems fine. You only realize something is not working correctly if the server returns an error, because the client ended up sending an invalid request. Or worse, the server doesn't give you an error because the file upload or whatever you were missing was optional, and you realize your mistake much later (maybe too late).


unimplemented! is already beeing used in some places of the template:

local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content"));

Some people already talked about compile_error! vs unimplemented!: #1890 (review)

There was also an idea about using the function return type ! instead, but I think this would be much harder to implement, given how the templates work. #1678 (comment)

I think unimplemented! would be the way to go for now.

openapi-generator version

6.6.0
7.0.0-SNAPSHOT

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

No branches or pull requests

1 participant