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
[C] C generator refactored #2463
Conversation
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
…so remove valgrind as it is not used
… to generate working codes
…rameters and fix some issues as per new changes in code flow structure
…r handling binary data and few more stuff
…nup external folder
|
||
api_response_free(respo); | ||
fclose(file); | ||
} else { | ||
apiClient_free(apiClient3); | ||
//apiClient_free(apiClient3); |
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 would suggest removing this line as it's commented out and people have no idea why it's left there.
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 updated it, as apiClient object has to be freed once the requirement is over. Modified all test samples accordingly.
|
||
|
||
// delete user test | ||
apiClient_t *apiClient5 = apiClient_create(); | ||
|
||
UserAPI_deleteUser(apiClient5, "example123"); | ||
apiClient_free(apiClient5); |
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.
Minor suggestion: indent apiClient_free
properly with reference to the previous line.
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.
You may simply want to use the code formatter to format the manually written test files.
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 have formatted manually written test files with uncrustify with the configuration we have in auto-generated code.
@zhemant what about using FILE* instead? It seems to me FILE* is pretty common for handling files in C. |
Yes, but this new structure is keeping in mind we also need to handle binary data which may not be a file pointer. In OAS3 binary and file are the same. And in curl, we need to pass the binary/file as data(char*/uint8_t) and its size. Hence to make it common for both data type user has to pass a struct of binary_t with data and length of data so it is easy to handle both files and binary while sending. In current codes for handling FILE* we are doing same, reading data into a struct with char* and length. |
@zhemant thanks for the explanation, which totally makes sense. |
Upgrade NoteBinary (type: string, format: binary) and file (OAS v2) are now mapped to the binary_t pointer ( |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,. Default:3.4.x
,4.0.x
master
.Description of the PR
Updated mustache for model and api to cover as much possible data types
Updated samples according to new mustaches
change data type from file to binary_t to handle binary data (support for OAS3)
Updated cmake mustache
@wing328