OpenAPITools / OpenAPITools/openapi-generator

[BUG] [scala-akka] Enum [de]serialization fails as the serializers are not loaded by default

Open
#21,841 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

Description

When using the default ApiInvoker for scala-akka clients for operations which use OpenAPI enum data types, opaque serializer errors are generated. This appears to be because no enum [de]serializers are loaded by default. This can be worked around by manually passing the generated, but unused, EnumSerializers.all list into the generated ApiInvoker constructor.

Background

While the scala-akka generator generates appropriate Scala code for enum datatypes, and also generates EnumsSerializers.scala which includes JSON serialization code for them, the default ApiInvoker does not include the enum serializers by default in its list of formats. EnumSerializers doesn't seem to be referenced anywhere else.

Workaround

To fix this, we have had to pass EnumsSerializers.all manually in the ApiInvoker constructor. This is done in the test for this generator too. This was non-obvious for us so hopefully this bug report can quickly resolve this for anyone else who stumbles upon this.

Steps to reproduce

Attempt to use the generated scala-akka clients to call any endpoint which has an enum response. This can presumably be done by running the pet store test without passing the EnumSerializers into the ApiInvoker.

Suggest a fix

Include EnumsSerializers.all in the default ApiInvoker constructor, as is done in this fork which I found while trying to diagnose our issue.

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 modules/openapi-generator/src/main/resources/scala-akka-client/apiInvoker.mustache and enumsSerializers.mustache, then inspect samples/client/petstore/scala-akka/src/test/scala/PetApiTest.scala. Run the petstore test without manually passing EnumSerializers.all; done means the default generated ApiInvoker handles enum responses successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.