Open aeneasr opened 2 years ago
I don't think rust client/server generator supports oneOf/anyOf at the moment.
May I know if you've time to make the contribution?
I can show you some reference implementations in other languages as a starting point.
It does :)
I fixed the problem here: https://github.com/OpenAPITools/openapi-generator/pull/13259
@wing328 Is there a chance that this gets fixed? The PR https://github.com/OpenAPITools/openapi-generator/pull/13259 is ready since a year. Maybe a comment why the PR might not be suitable so that we can work on it?
+1 - also waiting for it to be merged and can try to contribute additional fixes if needed
sorry for the delay in reviewing the fix.
I tested with
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g rust -i https://gist.githubusercontent.com/aeneasr/c201992378c87943dfdbe559adc32bae/raw/bdd23b17707b67c55b0ca7a3e128b198f5bbf0f3/openapi.json -o /tmp/rust2/
but couldn't repeat the issue by running cargo test
in /tmp/rust2
Compiling reqwest v0.11.22
Compiling openapi v0.2.0-alpha.13 (/private/tmp/rust2)
Finished test [unoptimized + debuginfo] target(s) in 1m 13s
Running unittests src/lib.rs (target/debug/deps/openapi-8cac114e773fb363)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests openapi
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Can you tell me more how to repeat the issue to confirm the fix?
Bug Report Checklist
Description
When using a spec which has a type that is a discriminator with multiple types, and at least two of those types have equal property names, the Rust generator fails to generate compilable code for that discriminator in cases where the conflicting key is also a type (e.g. an enum):
In the example above, the file
ui_node_attributes.rs
contains a large enum definition for the discriminator but is missingTypeEnum
:As you can see above, the two enums
TypeenumEnum
andAutocompleteEnum
are correctly marked as "enums" and included,TypeEnum
however is missing. This happens because theuiNodeScriptAttributes
also has a key calledtype
:which is clashing with the
type
field fromuiNodeInputAttributes
:I was able to identify this by adding the following debug statement to
model.mustache
of the Rust generator:which then showed that there is only one variable called
type
and it is coming from the script definition:https://gist.github.com/aeneasr/83cbb9013e589904332cab0482a765c1#file-ui_node_attributes-rs-L216-L219
If I change the order and move
#/components/schemas/uiNodeInputAttributes
below#/components/schemas/uiNodeScriptAttributes
, the enumTypeEnum
is correctly generated. However, this is only a temporary solution as it would still clashes with the other property definition.openapi-generator version
All versions of 5.x and 6.x are affected
OpenAPI declaration file content or url
https://gist.github.com/aeneasr/c201992378c87943dfdbe559adc32bae
Generation Details
Steps to reproduce
Use spec file https://gist.github.com/aeneasr/c201992378c87943dfdbe559adc32bae
Related issues/PRs
None
Suggest a fix
Looks like this has to be fixed outside of the templates and in the Java code base?