Openapi-generator: [BUG][Java][client] `mvn package` fails on Javadoc error

Created on 3 Jul 2019  路  4Comments  路  Source: OpenAPITools/openapi-generator

Bug Report Checklist

  • [*] Have you provided a full/minimal spec to reproduce the issue?

    • Any spec reproduces this, even the one included in samples

  • [*] Have you validated the input using an OpenAPI validator (example)?
  • [*] What's the version of OpenAPI Generator used?

    • seems all versions are affected, tested on 4.0.2 and master

  • [*] Have you search for related issues/PRs?
  • [*] What's the actual output vs expected output?

    • See below

  • [ ] [Optional] Bounty to sponsor the fix (example)
Description

Generated Java client (okhttp-gson) fails to build, erroring out on javadoc issues. This is reproducible even on samples/client/petstore/java/okhttp-gson for me. The output of mvn package is as follows:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:jar (attach-javadocs) on project petstore-okhttp-gson: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - javadoc: error - The code being documented uses modules but the packages defined in http://docs.oracle.com/javase/8/docs/api/ are in the unnamed module.
[ERROR] /Users/slavek.kabrda/programming/openapi-generator/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java:64: error: attribute not supported in HTML5: summary
[ERROR]      <table summary="Response Details" border="1">
[ERROR]             ^
# and many more error lines repeating the "table summary" error

It seems that there are 2 separate issues - the "table summary" being incorrect for HTML 5 and the other: "The code being documented uses modules but the packages defined in http://docs.oracle.com/javase/8/docs/api/ are in the unnamed module."

openapi-generator version

Seems to be both in 4.0.2 and current master.

OpenAPI declaration file content or url

Use the one included in samples.

Command line used for generation

None, just trying to build samples/client/petstore/java/okhttp-gson after cloning the repo.

Steps to reproduce
$ cd samples/client/petstore/java/okhttp-gson
$ mvn package
Related issues/PRs

None AFAICS.

Suggest a fix

For the first problem ("table summary"), we could probably easily fix the HTML to produce something that is compatible with HTML 5.

For the other issue, I guess the problem is a version combination of my JDK/maven, but I'm not a Java expert, so I don't know. Quick googling around didn't really help. My environment:

$ mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00)
Maven home: /usr/local/Cellar/maven/3.6.1/libexec
Java version: 12.0.1, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home
Default locale: en_CZ, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"
Bug Workaround available

Most helpful comment

The configuration below of the javadoc plugin works for me with AdoptOpenJDK 11.0.6:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <source>8</source>
          <doclint>none</doclint>
          <tags>
            <tag>
              <name>http.response.details</name>
              <placement>a</placement>
              <head>Http Response Details:</head>
            </tag>
          </tags>
        </configuration>
      </plugin>
  • Bump maven-javadoc-plugin to 3.x
  • Add configuration <source>8</source> property
  • Add configuration <doclint>none</doclint> property

All 4 comments

I couldn't repeat the issue locally (as I'm using Java 8). I'll leverage the CI to test different versions of JVM later to see if the issue occurs for a specified JVM version.

For the time being, please use -Dmaven.javadoc.skip=true as a workaround

FTR, I could only reproduce the issue using OpenJDK 11 and 12 from adoptopenjdk [1]. With their OpenJDK 8, this works fine for me too.

[1] https://github.com/AdoptOpenJDK/homebrew-openjdk

~Possible duplicate issue: #3299.~
~I think I have fixed it with https://github.com/OpenAPITools/openapi-generator/pull/3302~

~Can you give 4.0.3 a try?~


Can you provide what the correct HTML should be? It is easy to change.

In #3302 I have activated verification of Javadoc task in our CI, but I guess we are only testing with Java 8.
I need to check with @wing328 how we can run mvn --quiet javadoc:javadoc -Psamples.circleci on Java 11.

The configuration below of the javadoc plugin works for me with AdoptOpenJDK 11.0.6:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <source>8</source>
          <doclint>none</doclint>
          <tags>
            <tag>
              <name>http.response.details</name>
              <placement>a</placement>
              <head>Http Response Details:</head>
            </tag>
          </tags>
        </configuration>
      </plugin>
  • Bump maven-javadoc-plugin to 3.x
  • Add configuration <source>8</source> property
  • Add configuration <doclint>none</doclint> property
Was this page helpful?
0 / 5 - 0 ratings