openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] Generated Java code is importing javax.ws.rs.core.GenericType which doesn't exist

Open kwalcock opened this issue 2 years ago • 1 comments

Bug Report Checklist

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

The generated Java code includes

import javax.ws.rs.core.GenericType;

which doesn't compile.

openapi-generator version

openapi-generator-cli-6.2.0.jar

OpenAPI declaration file content or url
Generation Details

java -jar openapi-generator-cli-6.2.0.jar generate -i (input) -g java -o (output)

Steps to reproduce

Java 8.0 is being used locally.

Related issues/PRs
Suggest a fix

kwalcock avatar Oct 14 '22 10:10 kwalcock

  "javax.ws.rs" % "jsr311-api" % "1.1.1",
  "javax.ws.rs" % "javax.ws.rs-api" % "2.1.1",

kwalcock avatar Oct 14 '22 10:10 kwalcock

Same issue for me with 6.2.1 :

<execution>
  <id>client</id>
  <goals>
    <goal>generate</goal>
  </goals>
  <configuration>
    <inputSpec>${project.basedir}/src/main/resources/recordyaml</inputSpec>
    <generatorName>java</generatorName>
    <modelPackage>fr.model</modelPackage>
    <apiPackage>fr.api</apiPackage>
    <configOptions>
      <errorObjectType>fr.model.MediarecordResult</errorObjectType>
      <useJakartaEe>true</useJakartaEe>
      <sourceFolder>src/gen/java/main</sourceFolder>
    </configOptions>
  </configuration>
</execution>`

sylvaindd avatar Jan 24 '23 15:01 sylvaindd

I'm seeing the same issue with the 6.6.0 maven open api generator... The only change was to upgrade my generator version from a very old version to the latest (4.3.1 to 6.6.0.)

I believe i've narrowed this down to #11538 this line

Interesting enough i see another PR #9585 was done for 5.2.0 to remove this dependency, but some how it made it back in the okhttp-gson-nextgen PR (#11538) - i wonder if this was just a merge issue for this work?

Is the "solution" really to just add a dependency on javax.ws.rs to resolve this for now??

jakeswenson avatar Sep 05 '23 18:09 jakeswenson

Oh sweet, this looks to have been fixed in 7.0.0 by #15896 - thanks to @bcalvez!

jakeswenson avatar Sep 05 '23 18:09 jakeswenson