OpenAPITools / OpenAPITools/openapi-generator

[BUG][SCALA] Name conflict between Scala Any and generated Any

Open
#5,581 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Scala Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Generating a scala-akka client for Argo Workflows, I encounter a couple issues.

The first I've already reported here: https://github.com/OpenAPITools/openapi-generator/issues/5580

After replacing all three instances of ByteArray with Array[Byte], I try mvn clean install again.

I get the following error:

[ERROR] /home/.../src/argo-client-scala/src/main/scala/org/openapitools/client/api/EnumsSerializers.scala:44: error: overriding method serialize in trait Serializer of type (implicit format: org.json4s.Formats)PartialFunction[Any,org.json4s.JValue];
[ERROR]  method serialize has incompatible type
[ERROR]     def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {

This happens because Any in EnumsSerializers.scala refers to the generated org.openapitools.client.model.Any. If I change the name of that case class to ArgoAny and update all references besides the one in EnumsSerializers.scala, the build error goes away.

openapi-generator version

4.3.0-SNAPSHOT

OpenAPI declaration file content or url

https://raw.githubusercontent.com/argoproj/argo/20d6e27bdf11389f23b2efe1be4ef737f333221d/api/openapi-spec/swagger.json

Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/argoproj/argo/master/api/openapi-spec/swagger.json -g scala-akka -o ~/src/argo-client-scala --artifact-id argo-client-scala --artifact-version 0.1-SNAPSHOT --group-id com.crenshaw_dev -g scala-akka -o ~/src/argo-client-scala --artifact-id argo-client-scala --artifact-version 0.1-SNAPSHOT --group-id com.crenshaw_dev
Steps to reproduce
cd ~/src/argo-client-scala
mvn clean install
Related issues/PRs
Suggest a fix

Looks as if Any just isn't treated as a reserved keywork in scala-akka and should be. But I'm not certain.

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-akka generator using the linked Argo Workflows OpenAPI declaration, then inspect generated EnumsSerializers.scala alongside the generated model Any. Reproduce with mvn clean install; done means the generated Scala client compiles without the Any name collision.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.