Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !5699

Tests for models for C-libcurl generator

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/michelealbano/C_tests into master Mar 24, 2020
  • Overview 0
  • Commits 4
  • Pipelines 0
  • Changes 15

Created by: michelealbano

This PR first of all adds supports for models that contain other models as properties. In fact, this yaml could not be used with the master: https://gist.github.com/michelealbano/bd705d2bf5a1c36dde3e514a1c744f13

Moreover, I added support for the generation of tests for the generated models. I had to mix template and C, since I have access to different data from the 2 environments. From C I can build a "default" example, and/or decorate strings with double quotes. To be able to support objects into objects (a property of an "external" object is an "internal" object itself), I had to play with #ifdef and #include clauses:

  • I scan the properties (vars) of the external object, and for each internal object I will preliminary add the prototype of the function instantiate_{{classname}} that can instantiate the object before the generating instantiate_{{classname}} of the external object. I will then call the instantiate_{{classname}} where I am instantiating the external object.
  • I #include together all the test*.c files that I need, to build the a.out for the test. I will use #ifdef clauses to have just 1 main and not to repeat the function definition.

I had to change the name of the test*.c to play with #include of the files.

@ityuhui @zhemant

By the way, I wrote a python script to generate, compile and test a yaml file: https://gist.github.com/michelealbano/51e40ca2c403969bf98fb1ef7e2520c5 Example of usage: python ../doAllTests.py /mnt/hgfs/shared/miaroba/*.yaml

The PR is not complete - I still have to remove printf etc - but I wanted your comments.

PR checklist

  • [ X ] Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • [ X ] Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • [ X ] File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • [ X ] Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/michelealbano/C_tests