Update StaticHtmlGenerator to allow snake_case property names#2612
Update StaticHtmlGenerator to allow snake_case property names#2612wing328 merged 7 commits intoOpenAPITools:masterfrom
Conversation
…) method in DefaultCodegen and prevents underscores from being converted to the word Underscore
| wrapped: true | ||
| items: | ||
| type: string | ||
| favorite_food: |
There was a problem hiding this comment.
For petstore.yaml, we want to keep it as "original" as possible at the moment so please undo the change to petstore.yaml.
For this particular test, it should be already covered in the fake pestore spec: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
There was a problem hiding this comment.
Thanks for the feedback - good call. The change to petstore.yaml has been reverted.
|
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
|
|
||
| Assert.assertEquals(property.baseName, "favorite_food"); | ||
| Assert.assertEquals(property.name, "favorite_food"); | ||
| } |
There was a problem hiding this comment.
@farrez Thanks for adding the test case. Can the issue be also resolved by using baseName instead of name in the mustache templates as baseName should store the original property name defined in the spec.
There was a problem hiding this comment.
Yes that would also have worked.
There was a problem hiding this comment.
👌 I'll make the change with another PR.
| items: | ||
| type: string | ||
| tags: | ||
| tags: |
There was a problem hiding this comment.
What about removing this trailing space as well?
* master: (47 commits) [Slim] Fix AbstractAuthenticator constructor TypeError (#2641) Fix issue 1340 - StaticHtmlGenerator to allow snake_case property names (#2612) Test Gradle plugin in Appveyor CI (#2651) Add Camptocamp to company list (#2652) Use percent encoding for path parameters (#2649) Unescape HTML characters in JS docstring (#2636) [ONLINE] Minor links fix (#2644) better handling of undefined inner property in array (#2635) Fix regexp error on php-slim (#2604) [TypeScript-Fetch] Generate oneOf schemas as type unions (#2617) Add Namsor as the sponsor (#2639) fix classname in website (#2638) Code review fixes (#2633) Move Ruby module/gem to codegen constant (#2621) Add sponsor section to the website (#2634) [Spring] Spotbugs static class and default encoding (#2609) Add @Zomzog (2019/04) to Java, Kotlin tech comm (#2630) [maven] remove validateSpec (#2614) Clean up the license field in various templates to ensure it's unlicense by default. (#2627) Fix NPE when server url is null (#2628) ...
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif 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\.master,. Default:3.4.x,4.0.xmaster.@jhitchcock
@wing328
Description of the PR
(details of the change, additional tests that have been done, reference to the issue for tracking, etc)
The changes in this PR is an update to StaticHtmlGenerator so that it overrides the toVarName(String name…) method in DefaultCodegen and prevents "_" from being converted to the word "Underscore" on model property names. This should be a fix for #1340 where "snake_case" model property names are showing up as "snakeUnderscorecase" in the generated html.