OpenAPITools / OpenAPITools/openapi-generator

[BUG][Scala][scala-sttp] Schema with enums as reserved "names" get a bad variable name

Open
#12,226 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

When I generate a client for this schema (using circe for json library):

   PaginationInfo:
      type: object
      properties:
        type:
          type: string
          enum:
            - foo
            - bar

I get the following variable names for the JSON decoders and encoders:

  implicit val PaginationInfo`Type`Decoder: Decoder[PaginationInfoEnums.`Type`] = Decoder.decodeEnumeration(PaginationInfoEnums.`Type`)
  implicit val PaginationInfo`Type`Encoder: Encoder[PaginationInfoEnums.`Type`] = Encoder.encodeEnumeration(PaginationInfoEnums.`Type`)

Causing a compilcation error

openapi-generator version

5.4.0

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 reproducing the provided PaginationInfo schema with the scala-sttp generator and circe, then trace how enum properties such as the reserved name "type" become decoder and encoder variable names. Done means the generated Scala identifiers are valid and the generated client compiles without the shown error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.