OpenAPITools / OpenAPITools/openapi-generator

[BUG][C] "-" in Parametername is converted to "_"

Open
#5,101 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Version: 4.2.3-SNAPSHOT

 parameters:
      - name: x-api-token
          in: header
          description: Authorization Token
          required: false
          type: string

The generated code is:

 char* valueHeader_x_api_token;
  keyValuePair_t* keyPairHeader_x_api_token = 0;
  if (x_api_token) {
    keyHeader_x_api_token = strdup("x_api_token");
    valueHeader_x_api_token = strdup((x_api_token));
    keyPairHeader_x_api_token = keyValuePair_create(keyHeader_x_api_token, valueHeader_x_api_token);
    list_addElement(localVarHeaderParameters, keyPairHeader_x_api_token);
  }

but i would expect

keyHeader_x_api_token = strdup("x-api-token");

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 from the C generator's handling of OpenAPI header parameter names and compare the parameter identifier with the emitted header key. Use the supplied x-api-token example to verify that generated variable names remain valid while the emitted key preserves the original hyphenated name.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, openapi
Domain
devtools
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.