Skip to content
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] Adding petstore sample written in C #306

Merged
merged 37 commits into from
Jul 5, 2018

Conversation

PowerOfCreation
Copy link
Contributor

@PowerOfCreation PowerOfCreation commented Jun 13, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{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\.
  • Filed the PR against the correct branch: master, 3.1.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Features to be implemented:

  • authentication
  • sending data to the server(e.g. a json string)

Niklas Werner and others added 25 commits June 7, 2018 14:04
…has a proper constructor and a basic toJSON method
…o pointer for the enum status anymore; the pet struct can now be fully converted to json and parsed from json
@PowerOfCreation
Copy link
Contributor Author

PowerOfCreation commented Jun 13, 2018

resolves swagger-api/swagger-codegen#8206 @sconeu

@wing328 wing328 removed this from the 3.0.2 milestone Jun 16, 2018
@wing328 wing328 added the WIP Work in Progress label Jun 16, 2018
cJSON *jsonObject = pet_convertToJSON(pet);
cJSON_Delete(jsonObject);
}
apiClient_free(apiClient);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PowerOfCreation would it be possible to reuse the same apiClient across different operations/methods (e.g. petApi_addPet)?

We may also want to store authentication-related information (e.g HTTP username, password, API key, etc) in apiClient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried making it thread safe, but I could make a global variable apiClient too and reuse that in all methods. I will take a look, whether I can find a way to make it thread safe and reuse the apiClient.

Authentication related data can be stored in the apiClient when I have changed it, so it won't get created/deleted each time an operation is being performed.

@wing328
Copy link
Member

wing328 commented Jul 5, 2018

@PowerOfCreation this should be a good starting point. I'll start the reverse engineering process this weekend.

@wing328 wing328 merged commit 96e0814 into OpenAPITools:master Jul 5, 2018
@wing328 wing328 removed the WIP Work in Progress label Jul 5, 2018
@wing328 wing328 added this to the 3.1.0 milestone Jul 5, 2018
jimschubert added a commit to jimschubert/openapi-generator that referenced this pull request Jul 7, 2018
* master: (116 commits)
  3.1.0 release (OpenAPITools#486)
  Fix broken link to openapi generator plugin README (OpenAPITools#484)
  show warning message for nodejs server only (OpenAPITools#481)
  Add grokify to Go technical committee (OpenAPITools#479)
  [Slim] Improve codebase decouple (OpenAPITools#438)
  Ensure typescript samples are up to date (OpenAPITools#444)
  Update README.md
  [Golang][client] delete sample output dir before rebuild (OpenAPITools#477)
  update petstore samples (OpenAPITools#478)
  Revert "Improve Docker Tags (OpenAPITools#390)"
  update go client test dependencies (OpenAPITools#468)
  [Golang][client] fix for schema definition name `file` (OpenAPITools#433)
  Fix '.travis' file (syntax)
  make LICENSE GitHub display compatible (OpenAPITools#467)
  Improve Docker Tags (OpenAPITools#390)
  [Golang][client] fix file suffix for _test.go (OpenAPITools#449)
  Remove copy section (OpenAPITools#463)
  Add link to presentation (OpenAPITools#465)
  Use postProcessOperationsWithModels(Map, List) (OpenAPITools#431)
  [C] Adding petstore sample written in C (OpenAPITools#306)
  ...
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* Added a .gitignore to ignore the build folder

* Added a CMakeLists and a basic implementation of a double linked list

* Added the pet model

* changed the behaviour when a list gets freed - the data of each element doesn't get freed anymore

* Added the tool uncrustify in order to make code look better

* Uncrustified code

* added an implementation(constructor and deconstructor) for the category model

* Added a third party JSON library

* The pet struct now uses pointers for its members; the pet struct now has a proper constructor and a basic toJSON method

* The pet model now gets fully serialized into JSON

* Fixed the example url...

* Added third party library libcurl

* Modified category struct and added an unit test

* Added a foreach macro and added two functions

* Added a tag model and an unit test

* the pet struct now uses no double pointer for it's name anymore and no pointer for the enum status anymore; the pet struct can now be fully converted to json and parsed from json

* Added the struct APIClient and an unit test

* Uncrustified the unit test for category

* Added ifdef in pet.h to prevent errors

* Added one API endpoint to get a pet by id

* Added a "== 0" comparison that I forgot

* Added some kind of debug functionality to test-petApi.c

* Removed the DEBUG define

* Moved the c petstore example from samples/client/c to samples/client/petstore/c

* Renamed function getPetById to petApi_getPetById to avoid name collisions

* Removed unecessary method in list.c

* Added POST functionality; added petApi_addPet method and improved unit-test for petApi; cleaned up some code in apiClient

* removed two methods in list.c(string/tag to JSON) and moved their code directly in the pet_convertToJSON method

* Removed old, already commented out, puts artifact in apiClient.c

* Added a convertToJSON method to the category model

* Added a convertToJSON method to the tag model

* changed how the convertToJSON method works in the pet model

* Adjusted the unit-tests on how the convertToJSON method now works(now returns a cJSON* instead of a char*)

* apiClient_t now needs to be given to API methods as a parameter. This means apiClient_t can now be reused in multiple methods.

* Added an untested concept for how authentication could be handled

* Tested basicAuth using wireshark and added untested OAuth2 feature

* Added support for api key authentication using the http-header and tested functionality using wireshark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants