OpenAPITools / OpenAPITools/openapi-generator

[all] BUG: intentional underscore in front of fields getting removed on camelize

Open
#1,633 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Currently if we have an spec where one field (e.g. _links) is defined the current StringUtils replaces the first underscore on camelize. This doesn't seem right so I fixed it in my branch. However there are couple of Tests that fail then:
org/openapitools/codegen/go/GoModelTest.java:282
org/openapitools/codegen/php/PhpModelTest.java:284
and so on.
The correct behavior should be IMHO {"_sample", "_Sample"}, instead of {"_sample", "Sample"},

openapi-generator version

master HEAD 774013c7

OpenAPI declaration file content or url

https://gist.github.com/sruehl/18b8b704586ad7b39e488018c17ef7e5

Command line used for generation

generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/default $@

Steps to reproduce
  1. Generate
  2. look at api.ts and see that _links has become links and therefore is undefined at runtime.
Related issues/PRs

#1634

Suggest a fix/enhancement

keep the first underscore on camelCase

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating StringUtils and its camelize behavior, then run the mentioned org/openapitools/codegen/go/GoModelTest.java and org/openapitools/codegen/php/PhpModelTest.java tests. Confirm that leading underscores such as _sample remain in generated names while the expected camelized form is _Sample, and update affected expectations consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.