swagger-api / swagger-api/swagger-codegen

[cpprest] Dots and dashes are allowed in C++ identifiers.

Open
#8,460 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

When generating cpprest dots and dashes are allowed for C++ identifier names which causes uncompilable code like:

class  Io.k8s.kubernetes.pkg.api.v1.Service
    : public ModelBase
{
...
Swagger-codegen version

2.4.0-SNAPSHOT from docker hub: https://hub.docker.com/r/swaggerapi/swagger-codegen-cli/

Swagger declaration file content or url

https://raw.githubusercontent.com/kubernetes/kubernetes/v1.10.4/api/openapi-spec/swagger.json

Command line used for generation
docker run swaggerapi/swagger-codegen-cli generate  --lang cpprest --output /output -i https://raw.githubusercontent.com/kubernetes/kubernetes/v1.10.4/api/openapi-spec/swagger.json
Steps to reproduce

run:

docker run swaggerapi/swagger-codegen-cli generate  --lang cpprest --output /output -i https://raw.githubusercontent.com/kubernetes/kubernetes/v1.10.4/api/openapi-spec/swagger.json

After generating any class in model directory will have such invalid names.

Suggest a fix/enhancement

Maybe map dots to "_", but care must be taken to avoid name clashes.

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 running the documented Docker generation command against the Kubernetes Swagger declaration and inspect the generated files in the model directory. Trace how cpprest model class names are produced, then verify that dots and dashes no longer create invalid C++ identifiers and that the resulting names do not collide.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
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.