OpenAPITools / OpenAPITools/openapi-generator

[BUG] [JAVA] okhttp-gson joda client codegen ambiguous references for LocalDate and DateTimeFormatter

Open
#18,416 1 comment 2 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

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I'm trying to generate java client code with the default library template "okhttp-gson" and date library "joda".
The generated code has compile issues:

ApiClient.java:[337,39] error: reference to DateTimeFormatter is ambiguous both class org.joda.time.format.DateTimeFormatter in org.joda.time.format and class java.time.format.DateTimeFormatter in java.time.format match
and
JSON.java:[289,65] error: reference to LocalDate is ambiguous both class org.joda.time.LocalDate in org.joda.time and class java.time.LocalDate in java.time match

openapi-generator version

7.5.0

Suggest a fix

I believe the issue was introduced with commit: 8455c1cd23b980eb2449905ef7d2283119e44ff2
It would be fixed if java.time.format.DateTimeFormatter and java.time.LocalDate are not included in the ApiClient.mustache and the JSON.mustache

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 okhttp-gson Java templates named in the report: ApiClient.mustache and JSON.mustache, and inspect their imports for the joda and java.time classes. Regenerate a client using the okhttp-gson library with the joda date library and compile it; done means the generated ApiClient.java and JSON.java have no ambiguous DateTimeFormatter or LocalDate references.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.