swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[Kotlin] Reserved word in enum class name is not capitalized

Open atarynin opened this issue 2 years ago • 0 comments

Description

Problem occurres after generation model from API spec containing reserved word as enum

Swagger-codegen version

❯ swagger-codegen version 3.0.47

Swagger declaration file content or url
swagger: '2.0'
info:
  version: 0.0.0
  title: Simple API
paths:
  /:
    get:
      responses:
        200:
          description: OK

definitions:

  EnumModel:
    type: object
    properties:
      return:
        type: string
        enum: [ "1", "0" ]
Command line used for generation

swagger-codegen generate -l kotlin-client -i /swagger/test-spec.yaml

Steps to reproduce
  • Run tool for Model generation
  • Check generated folder
Related issues/PRs

https://github.com/swagger-api/swagger-codegen/issues/9948 https://github.com/swagger-api/swagger-codegen/issues/6393

Suggest a fix/enhancement

https://github.com/swagger-api/swagger-codegen-generators/pull/1196

Generated Model

The generated result that is caused compilation error and malformed property name in javadoc section

/**
 * Simple API
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 0.0.0
 * 
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */
package ru.tinkoff.bpm.test


/**
 * 
 * @param `return` 
 */
data class EnumModel (

    val `return`: `return`? = null
) {
    /**
    * 
    * Values: _1,_0
    */
    enum class `return`(val value: kotlin.String){
        _1("1"),
        _0("0");
    }
}

Complilation error image Malformed javadoc image

atarynin avatar Oct 11 '23 09:10 atarynin