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
  • #3804
Closed
Open
Issue created Aug 29, 2019 by Administrator@rootContributor

[BUG] [Kotlin] Enums are generated with odd capitalization

Created by: vitaliysapounov

Description

Kotlin generator generates Kotlin enums with strange capitalization: it lower-cases the first enum item letter (e.g. generates rED instead of RED).

openapi-generator version

Generator Version 4.1.1 Spec Version 3.0.2

OpenAPI declaration file content or url
openapi: "3.0.2"

info:
  version: "1.0.0"
  title: Testing Kotlin generation

# We only care about schemas, but this prevents codegen error: "attribute paths is missing"
paths:
  /dummy:
    get:
      responses:
        '200':
          description: OK

components:
  schemas:

    StatusColorEnum:
      description: >
        RGB.
      type: string
      enum:
        - RED
        - YELLOW
        - GREEN
Command line used for generation

openapi-generator generate -i my-models.yml -g kotlin

NOTE: we actually use the Gradle plugin for code generation (org.openapi.generator version 4.1.1), but the above command-line tool gives the same result. However, we would like the fix to propagate to the Gradle plugin as well, so we can use in our build.

Steps to reproduce

Run the command above and inspect the generated StatusColorEnum.kt. It will look like below:

package org.openapitools.client.models


import com.squareup.moshi.Json

/**
* RGB. 
* Values: rED,yELLOW,gREEN
*/
enum class StatusColorEnum(val value: kotlin.String){


    @Json(name = "RED")
    rED("RED"),


    @Json(name = "YELLOW")
    yELLOW("YELLOW"),


    @Json(name = "GREEN")
    gREEN("GREEN");


}

Note the capitalization is very odd: instead of rED it should really be just RED.

Related issues/PRs

Not found.

Suggest a fix

Generate Kotlin enums with the same capitalization as given in the declaration file (do not lower case the first letter).

Assignee
Assign to
Time tracking