OpenAPITools / OpenAPITools/openapi-generator

[BUG] [scala-pekko] Array of enums fails to generate valid code

Open
#23,399 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

https://github.com/OpenAPITools/openapi-generator/commit/72e942f81b2636ce69bfe32018de0ccb26bb1bd3 fix was applied for sttp generator. Same problem still occures with scala-pekko.

Tried with all the recent versions and 3.0.4, same issue occures

OpenAPI declaration file content or url
type: object
required:
  - id
properties:
  id:
    type: string
    format: uuid
  categoryKey:
    type: string
  templateKey:
    type: string
  stateFilters:
    type: array
    items:
      type: string
      enum:
        - state_new
        - state_pending
        - state_approved
        - state_rejected
        - state_archived

This generates invalid class where with typing

case class ConditionalActionGenericForIssue (
  id: UUID,
  categoryKey: Option[String] = None,
  templateKey: Option[String] = None,
  stateFilters: Option[ConditionalActionGenericForIssueEnums.Seq[StateFilters]] = None
) extends ApiModel

object ConditionalActionGenericForIssueEnums {

  type Seq[StateFilters] = Seq[StateFilters].Value

  object Seq[StateFilters] extends Enumeration {
  }

}

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 scala-pekko generator and compare its array-of-enums handling with the referenced sttp fix. Reproduce the issue using the YAML declaration in the report; done when the generated Scala code is valid and represents stateFilters as an array of enum values.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.