swagger-api / swagger-api/swagger-codegen

Codegen removes `$` from the name

Open
#11,771 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

codegen removes $ from the name

Swagger-codegen version

3.0.34

Swagger declaration file content or url
   "CommodityProduct": {
        "required": [
          "$type"
        ],
        "type": "object",
        "properties": {
          "$type": {
            "type": "string"
          },
...

generates

export interface CommodityProduct { 
    type: string;
...

expected:

export interface CommodityProduct { 
    $type: string;
...
Command line used for generation
java -jar ${__dirname}/swagger-codegen-cli-3.0.34.jar generate \
    -i ${config.swaggerPath} \
    -l typescript-angular \
    -o ${project} 
Steps to reproduce

just run command with such swagger file

Suggest a fix/enhancement

I have tried different --additional-properties, but it is still removing $ from the name. There should be some option to not rename keys from swagger file.

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

Reproduce the issue with the shown Swagger declaration and the swagger-codegen-cli 3.0.34 command using the typescript-angular generator. Start by tracing how the generator transforms the $type property name; done means generated TypeScript preserves $type instead of emitting type.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.