Created by: michelealbano
To fix #5091 (closed) that requires enums to be generated when the enum is in a param to a API call, instead than in a model. I did that by copying and adapting enum code from model-body.mustache to api-body.mustache, and from model-header.mustache to model-body.mustache.
To fix #4293 (closed) that needs to decorate enums, for when enum names or enum values are repeated over the yaml definition. I decorated the values of the enums in API's params as {{enumName}}{{{value}}}. The enum name did not need decoration. For models, I decorated the values as {{classFilename}}{{enumName}}{{{value}}}. The enum names were decorated as {{classFilename}}{{classname}}_e.
As with pre-PR version, string enums are well supported. If you provide me interesting YAML with other kinds of enums, I can add material to the mustache templates to support them too.
Take a look at this YAML: https://gist.github.com/michelealbano/88262eddc22966553055acc20fb6021f and to this main.c: https://gist.github.com/michelealbano/5ebb78590354af4785b345842891ae16
@zhemant @ityuhui
PR checklist
- [ X ] Read the contribution guidelines.
- [ X ] 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.