OpenAPITools / OpenAPITools/openapi-generator

[BUG] Generated code for scala-play-server does not compile for case classes with > 22 fields

Open
#9,341 1 comment 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

The output contains JSON serialization using play-json library, which is limited to case classes with 22 fields:

implicit lazy val myModelJsonFormat: Format[MyModel] = Json.format[MyModel]

If the case class MyModel has more than 22 fields, the code does not compile:

No unapply or unapplySeq function found for class MyModel: <none> / <none>
  implicit lazy val myModelJsonFormat: Format[MyModel] = Json.format[MyModel]

As the issue does not seem to be handled in Play (https://github.com/playframework/play-json/issues/3), I suggest using Jsonx (ai.x.play.json.Jsonx.formatCaseClass[MyModel]) for serialization of case classes with more than 22 fields like in this SO answer:
https://stackoverflow.com/a/57317220/1878731

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-play-server generation that emits Json.format[MyModel] and compare its behavior for case classes above the 22-field limit. Check whether using the suggested Jsonx formatter makes generated code compile for those models, while preserving serialization for smaller case classes.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Bug
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.