Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE caused by post block with array of strings #6745

Closed
inthegarage opened this issue Oct 19, 2017 · 4 comments
Closed

NPE caused by post block with array of strings #6745

inthegarage opened this issue Oct 19, 2017 · 4 comments

Comments

@inthegarage
Copy link

Description

A post section, with the the following section:

      parameters:
        - in: body
          name: body
          description: The list
          required: true
          schema:
            type: array
            items:
              type: string

causes an NPE.

Swagger-codegen version

2.2.3

Swagger declaration file content or url
  /my/endpoint:
    post:
      description: Returns a list
      operationId: getMyList
      parameters:
        - in: body
          name: body
          description: The list to retrieve as csv
          required: true
          schema:
            type: array
            items:
              type: string
      produces:
        - text/csv
      responses:
        '200':
          description: Ok
          schema: {
            type: string
          }
        '404':
          description: file not found
          schema:
            $ref: '#/definitions/errorModel'
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/errorModel'

  errorModel:
    type: object
    required:
      - code
      - message
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string

Command line used for generation

mvn clean compile

Steps to reproduce

Place the code into the defintion into a swagger file and compile it with the maven generator. It is not important which language variant you use the two I tried failed. (typescript and spring)

The error is:

Exception: null
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:861)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:764)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:388)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:700)
at io.swagger.codegen.plugin.CodeGenMojo.execute(CodeGenMojo.java:534)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.languages.AbstractJavaCodegen.needToImport(AbstractJavaCodegen.java:942)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2240)
at io.swagger.codegen.languages.AbstractJavaCodegen.fromOperation(AbstractJavaCodegen.java:1004)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:808)

Your help is appreciated.

@wing328
Copy link
Contributor

wing328 commented Oct 25, 2017

@inthegarage can you try the latest master (2.3.0)? SNAPSHOT version can be found in the README

@inthegarage
Copy link
Author

@wing328 I can confirm this is fixed in Master. Good work.

@inthegarage
Copy link
Author

Should I close or is it best you do so with a version reference?

@wing328
Copy link
Contributor

wing328 commented Oct 25, 2017

@inthegarage thanks for confirming the issue has been addressed in the latest master. I just closed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants