Open kevinwright opened 1 year ago
For a member that's a reserved word, several properties passed to the mustache template contain backticks.
for example, properties from debugModels:
{ "baseName" : "type", "getter" : "get`Type`", "setter" : "set`Type`", "name" : "`type`", "defaultValueWithParam" : " = data.type;", ..., }
Master
This occurs using any of the scala-based generators where the model contains a keyword
https://github.com/OpenAPITools/openapi-generator/issues/12226
Which incorrectly tags this as specific to just scala-sttp and enums
The properties getter, setter, nameInCamelCase and nameInSnakeCase should be based on the unquoted form of the member name.
getter
setter
nameInCamelCase
nameInSnakeCase
The root problem is that DefaultCodegen uses toVarName
toVarName
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L3636-L3641
also used here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L3842
But that happens after escaping: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java#L291
The quickest fix would be to override getterAndSetterCapitalize in AbstractScalaCodegen to not perform escaping
getterAndSetterCapitalize
AbstractScalaCodegen
Can you please file a PR with the suggested fix? let me know if you need any help with the PR.
Bug Report Checklist
Description
For a member that's a reserved word, several properties passed to the mustache template contain backticks.
for example, properties from debugModels:
openapi-generator version
Master
Generation Details
This occurs using any of the scala-based generators where the model contains a keyword
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/12226
Which incorrectly tags this as specific to just scala-sttp and enums
Suggest a fix
The properties
getter
,setter
,nameInCamelCase
andnameInSnakeCase
should be based on the unquoted form of the member name.The root problem is that DefaultCodegen uses
toVarName
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L3636-L3641
also used here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L3842
But that happens after escaping: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java#L291
The quickest fix would be to override
getterAndSetterCapitalize
inAbstractScalaCodegen
to not perform escaping