[BUG] initialCaps - camelize causing issues with CppRestSdkClientCodegen
Created by: osharav
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
Changes in #1821 have caused a regression in the cpp-restsdk. Usage of camelize in initialCaps removes underscores from the input string. The cpp-restsdk generator makes use of initialCaps in some areas and in some areas it relies on names without any modifications. One specific area where this can be seen involves the Inline Model Generator which creates names with underscores. The generator will create a file called InlineResponse200.h but with an include line: #include "Inline_response_200.h" for the cpp file.
openapi-generator version
v4.0.0-beta2
OpenAPI declaration file content or url
swagger: '2.0'
info:
version: 1.0.0
title: example-camelize
basePath: /api
paths:
/Entity/doStuff:
post:
tags:
- Entity
operationId: Entity.doStuff
responses:
'200':
description: Request was successful
schema:
type: object
properties:
count:
type: number
format: double
tags:
- name: Entity
consumes:
- application/json
produces:
- application/json
Command line used for generation
java -jar openapi-generator-cli.jar generate --skip-validate-spec -i example-camelize.yaml -g cpp-restsdk -o ./genExample
Steps to reproduce
Run the above and observe the generated cpp client: The generator will create a file called InlineResponse200.h but with an include line: #include "Inline_response_200.h" for the cpp file.
Compilation will fail.
Building and running exactly the same code only with StringUtils.capitalize instead of camelize in the initialCaps method produces Inline_response_200.h instead of InlineResponse200.h
Related issues/PRs
Could be related to #2003 (closed) - I'm unsure if the reporter used v3.3.4 (where the issue is not reproduced) or v3.4(?)
Suggest a fix
I have tried adding calls to initialCaps in CppRestSdkClientCodegen only to see more issues involving underscores show up. I would recommend reverting the change to use camelize - it might affect many other scenarios where underscores are introduced and then removed only in some cases. I would also recommend running CMake for the generated examples to catch this during the build - I will see if I can create a PR for this.
It's worth noting that other than this issue - v4.0.0-beta2 works great for us generating servers in cpp, python and clients in python, cpp and typescript.
Thanks a lot, Omer.