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

[cpp-pistache] Fix not processing enums in cpp-pistache-server #1366

Closed
wants to merge 1 commit into from

Conversation

mpreu
Copy link
Contributor

@mpreu mpreu commented Nov 2, 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.4.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

Fixes #1317

Defining a reusable enum as a component schema results in an empty
class. Following changes were made:

  • activate 'postProcessModelsEnum' in 'AbstractCppCodegen'
  • modify model templates for the 'cpp-pistache-server' project

As 'postProcessModelsEnum' is now available in the 'AbstactCppCodegen'
the 'enumVars' variables are now available in mustache templates for all
cpp based code generators.

As the 'AbstractCppCodegen' was touched all cpp based samples
are updated.

@ravinikam (2017/07) @stkrwork (2017/07) @fvarose (2017/11) @etherealjoy (2018/02) @MartinDelille (2018/03) @sebymiano

Defining a reusable enum as a component schema results in an empty
class. Following changes are made:

- activate 'postProcessModelsEnum' in 'AbstractCppCodegen'
- modify model templates for the 'cpp-pistache-server' project

As 'postProcessModelsEnum' is now available in the 'AbstactCppCodegen'
the 'enumVars' variables are now available in mustache templates for all
cpp based code generators.

As the 'AbstractCppCodegen' was touched all cpp based
samples were updated.
@etherealjoy etherealjoy changed the title Fix not processing enums in cpp-pistache-server [cpp-pistache] Fix not processing enums in cpp-pistache-server Nov 3, 2018
@etherealjoy
Copy link
Contributor

@mpreu
Nice PR. Thanks a lot.

Copy link
Contributor

@etherealjoy etherealjoy left a comment

Choose a reason for hiding this comment

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

I tried this PR and it looks good, need some minor adaptation
I used the Spec from #1317 and removed the anyOf, because it is buggy until we get the new PR #1360 for anyOf support integrated.

  • So in the mustache some change needs to be done to detect if it is an enum, because an enum is now created as a class and to serialize it . toJson and fromJson needs to handle it as well during serialization.
  • The enum description is missing in the enumeration declaration
  • Also need to check the case of integer.

@wing328
Copy link
Member

wing328 commented Mar 31, 2019

@mpreu Closing this due to no update. Please let us know if you still want to proceed with the change by resolving the merge conflicts

@wing328 wing328 closed this Mar 31, 2019
@mfyuce
Copy link
Contributor

mfyuce commented Mar 3, 2021

Hi,
Thanks for the PR.

What is it that needed to fix/reopen/merge this PR? I will help if needed.

Thanks a lot.

@wing328
Copy link
Member

wing328 commented Mar 3, 2021

@mfyuce can you please cherry-pick the commits and file a new one instead? Let me know if you need help on that.

@mfyuce
Copy link
Contributor

mfyuce commented Mar 3, 2021

Thanks @wing328 for the info. Let me work on that. Will inform.

@mfyuce
Copy link
Contributor

mfyuce commented Mar 4, 2021

Hi @wing328,

Have sent a PR at #8886. Hope it will be usefull.

All the best.

PS: Just a problem (may be not, currently evaluating), if the property in the api file has an "anyOf" field containing the enum value, the class generated (let us name "AnEnumClass") does not contain the enums, but a different class ("AnEnumClass_anyOf") has the enum variable. The problem is "AnEnumClass" does not reference "AnEnumClass_anyOf" in anyway. I have checked generated qt server server codes, the same problem is there also. What do you think? Is it a problem? I can inform if any problem after integrating it to our project at netas

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.

[cpp-pistache-server] Enumerations not generated
5 participants