swagger-api / swagger-api/swagger-codegen

[Kotlin] language keywords (e.g. 'break') can not be used as model names

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

When I use the codegen to produce Kotlin code for my "break" model, it produces uncompilable code

/**
 * Break details.
 * @param duration Duration of the break
 * @param endDate Date when the break ended
 * @param startDate Date when the break started
 */
data class `break` (
    /* Duration of the break */
    val duration: java.math.BigDecimal,
    /* Date when the break started */
    val startDate: java.time.LocalDateTime,
    /* Date when the break ended */
    val endDate: java.time.LocalDateTime? = null
) {

}
Swagger-codegen version

io.swagger.codegen.v3:swagger-codegen-cli:3.0.0

Suggest a fix/enhancement

What the Java generator does is rename to ModelBreak

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 with the Kotlin code generator and compare how the Java generator renames a model named "break" to "ModelBreak". Run the code generator using a model named "break", then verify that the generated Kotlin model compiles and that the model name is safely renamed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
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.