-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Fix a few issues with the C generator (part 1 version 2) #14434
Conversation
Some generated C apis fail to build because the source files get '#include "any_type.h"' lines, but no such header gets generated. As a simple fix, add a new template for an empty file with that name. This is enough to fix the problem for us, because all the generic type stuff is handled by object_t.
I'm guessing that enums have not been used much with the C generator before, because they always seem to produce code that doesn't build, or that tries to free them after use. This patch fixes all the problems we've encountered so far, except for those that need checking the return type. I'll come back to that later.
Currently, the C templates never check if a function returns an enum inside mustache, so when that happens the generated code has broken return types and doesn't build. I originally tried to fix this by extending CodegenOperation to implement a 'returnTypeIsEnum' check, but William Cheng suggested[1] that I use the existing 'returnProperty' instead: OpenAPITools#14379 (comment) So do that.
As required for a pull request, run the generate-samples.sh script and commit the changes.
@ityuhui what do you think is the best way to proceed with this PR? What about breaking it down into 4 smaller PRs to review and merge? |
Since it's been a long time since my last review, I will go through this PR recently to check if it can be merged or should break down into smaller PR. |
Hi! Thank you for looking into this again.
Because that's how
For our
But the
So the build will not go well, with warnings such as this one:
|
Hey, is there anything more I can do here? Do you want me to walk you through those two patches? |
I'm OK with this PR. Just wait for @wing328 to review and merge. |
Hey @wing328, is there anything more I can do to help here? |
Hi @wing328 I think this PR can merge now. |
@eafer can you please resolve the merge conflicts when you've time? sorry for the delay in getting it merged. you may want to update |
@wing328 I did the backmerge you requested. I'll try to look into the test schemas later, but it's been a while and I'm struggling to get things to build again. |
updated samples via e3dfe90 |
just merged it. thanks again for the PR. if i can find the time later, i'll update the c petstore spec to add some tests too. |
The recent commit 47665aa ("Fix a few issues with the C generator (part 1 version 2) (OpenAPITools#14434)") didn't include any test schemas. Add them now, as requested: OpenAPITools#14434 (comment)
@eafer thank you. will review and get it merged shortly |
* [C] Add test schemas for the recent changes The recent commit 47665aa ("Fix a few issues with the C generator (part 1 version 2) (#14434)") didn't include any test schemas. Add them now, as requested: #14434 (comment) * Update samples * Fix sample update with missing files * More fixes for sample updates
This is a second version of the pull request from #14388. The differences with the first version are:
object_t
, as requested by @ityuhuiConfig.cmake.in
file was cleaned up (I think it showed up in the first place because I forgot to rebuild before running the script)returnTypeIsEnum
was abandoned and replaced withreturnProperty
, following the instructions by @wing328These patches fix a few compilation errors for this api's generated code, but they are not enough by themselves to get it to build. More patches will be submitted later.