Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2145
Closed
Open
Issue created Feb 13, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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.

Assignee
Assign to
Time tracking