swagger-api / swagger-api/swagger-codegen

[FINCH] no enum support

Open
#4,863 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature Feature: Enum help wanted Server: Scala
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The Finch code generator does not support enums. An inline enum generates a normal variable of the desired type; a referenced enum generates an empty case class.

Swagger-codegen version

2.2.2-SNAPSHOT

Swagger declaration file content or url
      resultCode:
        type: string
        enum: [
          "OK",
          "EXCEPTION",
          "BAD_REQUEST"
        ]
Suggest a Fix

As far as I know there is no single best implementation choice for enumerations in scala. Possible choices are:

  • scala enumeration class (no warning for non-exhaustive match, type erasure issues)
  • sealed case objects (no easy way of iterating through values, no default serialization / deserialization)
    The serialization issue might not be a problem if circe supports it; still, scala enumerations might be easier to implement.

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 by locating the Finch generator entry points for inline and referenced schemas and reproduce both outputs from the supplied YAML. Compare the generated variable and empty case class with the intended enum representation; done requires an agreed Scala representation and coverage for both cases, including serialization behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.