OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.77k stars 6.57k forks source link

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

Open mirelon opened 3 years ago

mirelon commented 3 years ago

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

gavnewalkar commented 2 years ago

This is a known bug with with case classes with 22+ variables: https://blog.datumbrain.com/2018/10/22/json-format-more-than-22-case-class.html