[BUG][C++] Avoid using plain underscore when escaping reserved words#5269
Conversation
|
@alexweav thanks for the PR. What about adding an option We can default it to |
|
@wing328 @etherealjoy Apologies for the slow response on this. I added a CLI option, I made this change in the base abstract generator for C++, but I noticed that the CppRestSdkClientCodegen actually clears all CLI options inherited from its base class. Removing this clear-all brought in more unwanted options, so I instead opted for adding the option directly to the CppRest class too. Is there a better way of working around this? Since this option was added to the base abstract generator, it will be inherited by all other C++ generators which do not clear their inherited options. I noticed that the CppPistacheServer generator and the CppRestbedServer generator also clear their inherited options, but the other C++ generators don't. If you would like, I can explicitly add this option to these two as well, following the same approach I took for the CppRest generator. However, if there is a different/more generic approach that you would prefer, please let me know. |
|
LGTM. modified: docs/generators/cpp-qt5-client.md
modified: docs/generators/cpp-qt5-qhttpengine-server.md
modified: docs/generators/cpp-restsdk.md
modified: docs/generators/cpp-tizen.mdI was going to suggest the reserved keyword prefix be left as _ but i realized it will not compile on Windows MSVC. |
Please file another PR with the same approach to do so. Thank you. |
Posted: #5418 |
…penAPITools#5269) * Don't use plain underscore when escaping reserved words * Regenerate petstore output * Add CLI option for reserved word prefix * Ensure CLI option isn't cleared in cpprest client codegen * Regenerate docs
|
@alexweav thanks for the PR, which has been included in the 4.3.0 release: https://twitter.com/oas_generator/status/1243455743937789952 |
Fixes #5268 as described in the issue. Are there any better preferred ways of escaping this?
Ran the generator against the file given in the issue, and verified that the output now compiled using MSVC-14. Repeated below, for ease of use:
PR checklist
./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.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.