Skip to content

[BUG][KOTLIN] Bug generator Kotlin client definition with multiple enums #3917

Closed
@andrewemery

Description

@andrewemery
Description

Generating a Kotlin client that contains a definition with multiple enums produces invalid output.

openapi-generator version

4.1.2

OpenAPI declaration file content or url
definitions:
  Pet:
    required:
        - one
        - two
    properties:
      one:
        type: string
        enum:
          - 'A'
          - 'B'
      two:
        type: string
        enum:
          - 'C'
          - 'D'
Command line used for generation
openapi-generator generate -g kotlin
Output
data class Pet (
    @Json(name = "one")
    val one: Pet.One,
    @Json(name = "two")
    val two: Pet.Two
)

{
    /**
    * 
    * Values: a,b
    */
    
    enum class One(val value: kotlin.String){
    
        @Json(name = "A") a("A"),
    
        @Json(name = "B") b("B");
    

    }
}

{
    /**
    * 
    * Values: c,d
    */
    
    enum class Two(val value: kotlin.String){
    
        @Json(name = "C") c("C"),
    
        @Json(name = "D") d("D");
    

    }
}
Expected output
data class Pet (
    @Json(name = "one")
    val one: Pet.One,
    @Json(name = "two")
    val two: Pet.Two
)

{
    /**
    * 
    * Values: a,b
    */
    
    enum class One(val value: kotlin.String){
    
        @Json(name = "A") a("A"),
    
        @Json(name = "B") b("B");
    

    }
    /**
    * 
    * Values: c,d
    */
    
    enum class Two(val value: kotlin.String){
    
        @Json(name = "C") c("C"),
    
        @Json(name = "D") d("D");
    

    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions