Open felixauringer opened 7 months ago
Yes, I confirm this bug with generated code for Twilio API:
openapi-generator generate -g rust \
-i https://raw.githubusercontent.com/twilio/twilio-oai/main/spec/json/twilio_api_v2010.json \
-o twilio_rust \
--additional-properties=useSingleRequestParameter=true
error[E0433]: failed to resolve: could not find `serde_json` in `models`
--> /Users/tom/twilio_test/twilio_rust/src/apis/api20100401_payment_api.rs:40:35
|
40 | pub parameter: Option<models::serde_json::Value>,
| ^^^^^^^^^^ could not find `serde_json` in `models`
|
help: consider importing this crate
|
12 + use crate::serde_json;
|
help: if you import `serde_json`, refer to it directly
|
40 - pub parameter: Option<models::serde_json::Value>,
40 + pub parameter: Option<serde_json::Value>,
|
For more information about this error, try `rustc --explain E0433`.
error: could not compile `openapi` (lib) due to 1 previous error
I can also confirm this is a problem. Any idea on whether this is a twilio problem or an openapi-generator problem?
Bug Report Checklist
Description
If a request parameter has an empty schema (
schema: {}
), the produces rust code is invalid (does not compile). According to the OpenAPI validator linked above and the official specification, this is a valid spec.The OpenAPI spec below produces a function with the following signature:
This cannot be compiled, the error message is
could not find 'serde_json' in 'models'
. I would expect that all code generated from a valid OpenAPI spec generates compilable rust code.openapi-generator version
I tested with version 06ed7c82056aace4651d65ec56b68e4520739b53 (the current main).
OpenAPI declaration file content or url
Steps to reproduce
I'll provide the steps to create a failing test using the valid OpenAPI spec above.
Add the snippet above to the test resources (e.g.
modules/openapi-generator/src/test/resources/3_0/rust/empty-schema.yaml
).Create a config for the test (e.g.
bin/configs/rust-reqwest-empty-schema.yaml
):Generate the rust samples with
./bin/generate-samples.sh ./bin/configs/rust-*
.Execute the tests with
mvn integration-test -f samples/client/others/rust/pom.xml
.Related issues/PRs
I did not find any issues regarding empty schemas and rust.
Suggest a fix
I'm new to rust and to openapi-generator, so I am no help here, sorry.