-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
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).
openapi-generator/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
Line 269 in 7f8b853
| // 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:
openapi-generator/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
Line 301 in 7f8b853
| 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