swagger-api / swagger-api/swagger-codegen

Clients : invalid variables/functions generated names

Open
#6,387 6 comments 0 reactions 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

Using swagger codegen with the Fitbit Api results in invalid function names.
For instance, the API with URL:

/1/user/-/activities/date/{date}.json

Is generated with the following name:

1UserActivitiesDateDateJsonGetWithHttpInfo

Which won't compile. I suspect that the '1' in the url is a version number... So I prefixed all affected APIs with 'v', so it becomes:

v1UserActivitiesDateDateJsonGetWithHttpInfo

That is then valid.

I'm running swagger-codegen 2.2.3 on Mac OS X, installed with Homebrew.
To reproduce the issue, launch the following command:

swagger-codegen generate -i https://dev.fitbit.com/docs/explore/fitbit-web-api.swagger.json -l csharp

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 problem with the Fitbit specification and the command swagger-codegen generate -i https://dev.fitbit.com/docs/explore/fitbit-web-api.swagger.json -l csharp. Trace how the C# generator derives operation names from the /1/user/... path, then verify that generated names are valid C# identifiers and compile successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.