-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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 Client] several small fixes to code generation errors #8845
Conversation
See these simple test cases:
Each includes the errors currently produced by master |
This PR does get much further than the latest release in generating the client that I'm interested in (docspell's). Generating from the linked .yml file results in these
|
cc @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) |
Hey @wing328 -- how can I help to move this forward? Thanks. |
@ahl did you see the issues reported by @antifuchs when he tried your PR/fix? Are you able to reproduce those locally? |
Yes, he said "This PR does get much further than the latest release in generating the client that I'm interested in..." i.e. that it's a significant improvement over the latest version. The Rust generator struggles with quite a few constructions--too many for me to fix in this PR. With over 2k open issues, it's a little hard to understand what's filed or not, but from the output @antifuchs posted I recognize several issues that exist independent of this PR:
|
Totally agree on that. My question is wondering if you've looked into the issue he reported and the finding, and it's perfectly fine to have another PR to fix those instead of squeezing all the fixes into one giant PR.
We are definitely looking for contributors to help on that as we've already come up with the implementation in some other generators (java, csharp, go, python, and more). We can use these as the reference implementations to start with. I'll take another look over the weekend and merge if no further feeddback/question from me. Thanks again for the PR. Have a nice weekend. |
Thanks, William. Yes I was able to reproduce those. I have some ideas about how to fix them, but this code feels quite fragile. I'm unsure about test coverage and wouldn't be confident that a fix in one place wouldn't regress another. In this PR I tried to stick to some pretty clear wins like resolving a fundamental issue with circular types. |
// TODO: deleting the variable from the array was | ||
// problematic; I don't know what this is supposed to do | ||
// so I'm just cloning it for the moment | ||
List<CodegenProperty> vars = new ArrayList<>(model.getVars()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahl when you've time, can you please elaborate on the problem ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sorry to leave that turd. This code section seems to be handling discriminators and relocates a particular variable into the discriminators variables. It previously did so destructively which caused the original variable to be absent.
This is definitely ugly and poorly structured, but I don't have a good sense of how it should be structured or how to properly and exhaustively test some of the subtle semantics here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries bro. Do you have a spec that can reproduce the issue that you encountered with this line/section of code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was running the influxdb openapi spec through it: https://docs.influxdata.com/influxdb/v2.0/api/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Will take a look when I can find the time later.
@antifuchs I wonder if you can open an issue with the details to track the problem you reported above. Thanks. |
@thanks for the PR, which has been included in the v5.1.0 release: https://twitter.com/oas_generator/status/1373636654024380423 |
This fixes a few rust code generation issues. I've included links to small test cases.
crate::models::crate::models::...
File
Closes #8380
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x