Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #12531
Closed
Open
Issue created Jun 03, 2022 by Administrator@rootContributor

[BUG] [Kotlin-client] Handling default value of enum parameter

Created by: joethehoff

OpenAPIGenerator 6.0.0 produces incorrect kotlin code for a enum parameter with default value.

https://gist.github.com/joethehoff/7373e4b91b57531df6dc15162803f095

The generator produces following code:

@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
    fun workOrdersGet(color: Color_workOrdersGet? = blue) : Unit {...}

    /**
     * enum for parameter color
     */
     enum class Color_workOrdersGet(val value: kotlin.String) {
         @Json(name = "blue") blue("blue"),
         @Json(name = "red") red("red"),
         @Json(name = "yellow") yellow("yellow"),
         @Json(name = "black") black("black")
     }

The kotlin compiler produces the error message: Unresolved reference: blue

The generator configuration:

<configuration>
    <inputSpec>${project.basedir}/api/work-api.json</inputSpec>
    <generatorName>kotlin</generatorName>
    <generateApiTests>false</generateApiTests>
    <generateModelTests>false</generateModelTests>
    <apiPackage>xxx.controller</apiPackage>
    <modelPackage>xxx.gen.model</modelPackage>
    <apisToGenerate>WorkOrderServiceV2</apisToGenerate>
    <skipValidateSpec>true</skipValidateSpec>
    <configOptions>
        <enumPropertyNaming>camelCase</enumPropertyNaming>
    </configOptions>
    <additionalProperties>interfaceOnly</additionalProperties>
</configuration>
Assignee
Assign to
Time tracking