swagger-api / swagger-api/swagger-codegen

[Kotlin] Restricted keyword in package

Open
#9,502 0 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

Description

It seems that when using restricted keyworkds in the package, this will not be escaped.

eg. "in" is a keyword in kotlin (as the source code list it as well), and is also the domain of india.
The config.json for my kotlin-client generation looks like:

{ "modelPackage" : "in.test.client.model", }

and produces "package in.test.client.model", which does not compile.
It would need to be "package in.test.client.model"

This issue might be the same for domains like "is","it" and so on.

Swagger-codegen version

Swagger v.3.0.8

Command line used for generation

using the config as above by using domain which is reserved
-c config.json

Steps to reproduce

Use for example package like described above "in.test.client.model"

Suggest a fix/enhancement

There is already the escapeReservedWord method in AbstractKotlinCodegen and should be used for every package substring, splitted at the delimiter "."

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 in AbstractKotlinCodegen and inspect the existing escapeReservedWord method, then trace how modelPackage is split and emitted. Reproduce the issue with the config using in.test.client.model. Done means each dot-separated package component is handled so the generated Kotlin package declaration compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.