OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
22k stars 6.6k forks source link

[BUG] Java Maven Openapi generator returns a Null Pointer Exception. #6562

Open otaviojava opened 4 years ago

otaviojava commented 4 years ago

Bug Report Checklist

Description

I did the validation in the YAML file and it passes, however, when I try to generate the code from this YAML file API it returns the error below:

  Exception: null
    at org.openapitools.codegen.DefaultGenerator.processOperation (DefaultGenerator.java:1204)
    at org.openapitools.codegen.DefaultGenerator.processPaths (DefaultGenerator.java:1098)
    at org.openapitools.codegen.DefaultGenerator.generateApis (DefaultGenerator.java:556)
    at org.openapitools.codegen.DefaultGenerator.generate (DefaultGenerator.java:1008)
    at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:746)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException
    at org.openapitools.codegen.DefaultCodegen.fromRequestBodyToFormParameters (DefaultCodegen.java:5458)
    at org.openapitools.codegen.DefaultCodegen.fromOperation (DefaultCodegen.java:3506)
    at org.openapitools.codegen.languages.AbstractJavaCodegen.fromOperation (AbstractJavaCodegen.java:1226)
    at org.openapitools.codegen.DefaultGenerator.processOperation (DefaultGenerator.java:1172)
    at org.openapitools.codegen.DefaultGenerator.processPaths (DefaultGenerator.java:1098)
    at org.openapitools.codegen.DefaultGenerator.generateApis (DefaultGenerator.java:556)
    at org.openapitools.codegen.DefaultGenerator.generate (DefaultGenerator.java:1008)
    at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:746)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
openapi-generator version
OpenAPI declaration file content or url

The URL code: https://github.com/platformsh/platformsh-client-java/blob/master/src/main/resources/api.yaml

Command line used for generation

On this project source code: https://github.com/platformsh/platformsh-client-java We run this command:

mvn clean package
Steps to reproduce
git clone git@github.com:platformsh/platformsh-client-java.git
cd platformsh-client-java
mvn clean package
Related issues/PRs
Suggest a fix
shivankpandey2 commented 3 years ago

Any luck on this, getting the same exception on version 5+.

bhushanshinde07 commented 2 years ago

Hi All, Any luck on above issue. I am also facing same issue in openapi-generator.version 5.4.0 but it was working with openapi-generator.version 5.3.0.

Could you please give me resolution steps to resolve the above issue?

otaviojava commented 2 years ago

I worked on version 5.3.0.