OpenAPITools / OpenAPITools/openapi-generator

[BUG] Description

Open
#11,637 1 comment 1 reaction 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
  • [x ] Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • [x ] Have you tested with the latest master to confirm the issue still exists?
  • [x ] Have you searched for related issues/PRs?
  • [x ] What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am creating an extension to generate code for a project that uses proprietary libraries. To do that I used the

       java -jar ../bin/openapi-generator-cli.jar meta

command, that generates a maven project in my working directory. When invoking "mvn package" this generates an error. The details of the error message is included below, but the essence is that this line in DefaultGeneratorTest.java fails to compile:

  generator.opts(clientOptInput).generate();

... it fails because the compiler does not recognize that the "generator" instance has a method "opts" that can be invoked.

openapi-generator version

5.4.0

Also tried to download and install 6.0.0-SNAPSHOT (and updated pom.xml to use it), but still observed the same result.

OpenAPI declaration file content or url

Not relevant. The code crashes before any .yaml file is read (I also tested with the petstore.yaml in place, and the failure mode is identical).

Generation Details
Steps to reproduce
 java -jar ../bin/openapi-generator-cli.jar meta
 mvn package

(also reproduces for mvn commands "test" and "install", equivalent result produced from inside of intellij under windows11).

Details produced by maven when running mvn package

Notes:

  • Paths has been redacted
  • The runtime environment was Ubuntu 20.04 running under WSL2 with java version openjdk 11.0.13 2021-10-19, OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04)
  • The same behavior was also observed on windows 11 openjdk 17.0.1 2021-10-19 LTS, OpenJDK Runtime Environment Microsoft-28056 (build 17.0.1+12-LTS) (logs not included).
      $ mvn package                                           
      WARNING: An illegal reflective access operation has occurred                                             
      WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)                                                                              
      WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1                                                                                               
      WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations    
      WARNING: All illegal access operations will be denied in a future release                                
      [INFO] Scanning for projects...                                                                          
      [INFO]                                                                                                   
      [INFO] -------------< org.openapitools:default-openapi-generator >-------------                          
      [INFO] Building default-openapi-generator 1.0.0                                                          
      [INFO] --------------------------------[ jar ]---------------------------------                          
      [INFO]                                                                                                   
      [INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (enforce-maven) @ default-openapi-generator ---        
      [INFO]                                                                                                   
      [INFO] --- build-helper-maven-plugin:3.0.0:add-source (add_sources) @ default-openapi-generator ---      
      [INFO] Source directory: <REDACTED-DIRECTORY>/src/main/java added.                    
      [INFO]                                                                                                   
      [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ default-openapi-generator ---      
      [INFO] Using 'UTF-8' encoding to copy filtered resources.                                                
      [INFO] Copying 4 resources                                                                               
      [INFO]                                                                                                   
      [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ default-openapi-generator ---         
      [INFO] Changes detected - recompiling the module!                                                        
      [INFO] Compiling 1 source file to <REDACTED-DIRECTORY>/target/classes                 
      [INFO]                                                                                                   
                                                                                                                                                                                                            [INFO] --- build-helper-maven-plugin:3.0.0:add-test-source (add_test_sources) @ default-openapi-generator ---                                                                                                     
      [INFO] Test Source directory: <REDACTED-DIRECTORY>/src/test/java added.               
      [INFO]                                                                                                   
      [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ default-openapi-generator ---                                                                                                       
      [INFO] Using 'UTF-8' encoding to copy filtered resources.                                                
      [INFO] skip non existing resourceDirectory <REDACTED-DIRECTORY>/src/test/resources    
      [INFO]                                                                                                   
      [INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ default-openapi-generator --- 
      [INFO] Changes detected - recompiling the module!                                                        
      [INFO] Compiling 1 source file to <REDACTED-DIRECTORY>/target/test-classes            
      [INFO] -------------------------------------------------------------                                     
      [ERROR] COMPILATION ERROR :                                                                              
      [INFO] -------------------------------------------------------------                                     
      [ERROR] <REDACTED-DIRECTORY>/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java:[34,14] cannot find symbol
      [ERROR]    symbol:   method opts(org.openapitools.codegen.ClientOptInput)
      [ERROR]    location: variable generator of type org.openapitools.codegen.DefaultGenerator                         
      [INFO] 1 error                                                                                           
      [INFO] -------------------------------------------------------------                                     
      [INFO] ------------------------------------------------------------------------                          
      [INFO] BUILD FAILURE                                                                                     
      [INFO] ------------------------------------------------------------------------                          
      [INFO] Total time:  3.630 s                                                                              
      [INFO] Finished at: 2022-02-17T10:52:47+01:00                                                            
      [INFO] ------------------------------------------------------------------------                          
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile (default-testCompile) on project default-openapi-generator: Compilation failure                                   
      [ERROR] <REDACTED-DIRECTORY>/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java:[34,14] cannot find symbol                                                                       
      [ERROR]   symbol:   method opts(org.openapitools.codegen.ClientOptInput)                                 
      [ERROR]   location: variable generator of type org.openapitools.codegen.DefaultGenerator                 
      [ERROR]                                                                                                  
      [ERROR] -> [Help 1]                                                                                      
      [ERROR]                                                                                                  
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.                      
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.                                   
      [ERROR]                                                                                                  
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException  

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 by generating the Maven project with java -jar ../bin/openapi-generator-cli.jar meta, then inspect DefaultGeneratorTest.java, especially the generator.opts(clientOptInput).generate() call. Run mvn package or mvn test to reproduce the compilation failure; done means the generated project compiles successfully without the missing opts method error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.