-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] [Rust] fails to compile discriminator if multiple oneOf definitions use the same key names #13257
Comments
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: #13259 |
+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
but couldn't repeat the issue by running
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?
The text was updated successfully, but these errors were encountered: