Openapi-generator: Enhancement to the C client generator

Created on 16 Nov 2018  路  12Comments  路  Source: OpenAPITools/openapi-generator

Description

Below please find a list of pending enhancements to the C client generator:

  • [ ] Change required cURL version to 7.58.0
  • [ ] Fix authentication methods(either with a new #define or by only generating the correct code snippet)
  • [ ] Allow multiple uses of the apiClient_t object
  • [ ] Build as library
  • [ ] Add build target "make install"
  • [ ] Provide/Document an example how to use the generated code for a client
  • [ ] Better Unit-Tests
  • [ ] Better cURL/HTTP error code handling
openapi-generator version

Latest master

Related issues/PRs

226 #516

Suggest a fix/enhancement

If anyone wants to help on this, please reply to let us know.

C General help wanted

Most helpful comment

UPDATE: The mustache for C codegen have been updated also Cmake file has been updated.
@stdevMac: Please check PR #2463, In updated petstore sample if you check the cmakefile now it explains how to link the generated library to your respective code. Everything in unit-tests folder represents your test code which will be using this library. Also, the library works as path dependent so you only need to include api header file from api folder with proper path. As an example you can check manual-PetAPI.c in the unit-tests folder.

Let me know if you encounter any issue

All 12 comments

Hi guys, i need some help
I am trying to use a C client generated by openapi-generator, and there is not any place where i found clearly what i need to use it.
I think i need to compile the library and then link this library to the code where i need to use it
Can someone help me with this?
Thanks

As discussed, the C Petstore integration test is a good reference: https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/c/unit-tests/manual-PetAPI.c

And the installation procedure can be found in the auto-generated README

@wing328 The installation procedure is not really clear, you explain how to use it, but if you want to compile it, and use C as a external link, you don't say nothing
In petstore case, i compile successfully the library, i guest the generator isn't work propertly for some instance, pls check that

@stdevMac can you please share the command to compile the library?

I totally agree with you that the documentation can be further improved.

cc @zhemant

I think this line is generic for any project so, maybe you can include it in your README.md for everyone that need it

$ gcc $(find . -name '*.c')  -I ./model -I ./include -I ./external/include -o some_output.out -lcurl

This step just work before install curl and incrustify

Do you mind filing a PR to update the readme mustache file so that the credit goes back to you?

@stdevMac if you okay with using cmake, I will add a cmake file for petstore example which will make handling more easier. And I will update instructions about same in Readme.
About object.c/h I will be adding templates of those in some time. I have those templates almost ready.

pls @zhemant let me know when templates were ready, thanks

@wing328 sure, just gave me time and i will do my best in the README, thanks for counting on me

@stdevMac please check #2377 I have added template for object.c/h also modified the readme. The client codes which samples/petstore are not updated please refer README generated by the new codes. I will be modifying the model and api mustache in this week so that most of the stuff required by OAS2 and OAS3 will be covered

UPDATE: #2377 has been merged into master

UPDATE: The mustache for C codegen have been updated also Cmake file has been updated.
@stdevMac: Please check PR #2463, In updated petstore sample if you check the cmakefile now it explains how to link the generated library to your respective code. Everything in unit-tests folder represents your test code which will be using this library. Also, the library works as path dependent so you only need to include api header file from api folder with proper path. As an example you can check manual-PetAPI.c in the unit-tests folder.

Let me know if you encounter any issue

Was this page helpful?
0 / 5 - 0 ratings