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 generatinginstantiate_{{classname}}
of the external object. I will then call theinstantiate_{{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.