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

[all] Fix NullPointerException with list of simple types #680

Merged
merged 1 commit into from
Jul 29, 2018

Conversation

jmini
Copy link
Member

@jmini jmini commented Jul 29, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 4.0.x. Default: master.
  • Copied the technical committee: @OpenAPITools/generator-core-team (change to DefaultCodegen)

Description of the PR

Fixes #677

There is a null pointer for when request body is an array of items that are simple-types:

      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: string

This PR set the name to request_body for those cases (as it is the case for map).
A Unit Test is added.


Stacktrace before the fix:

  Exception: null
	at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:942)
	at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:836)
	at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:463)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:794)
	at org.openapitools.codegen.cmd.Generate.run(Generate.java:315)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:59)
Caused by: java.lang.NullPointerException
	at org.openapitools.codegen.DefaultCodegen.underscore(DefaultCodegen.java:3129)
	at org.openapitools.codegen.languages.PerlClientCodegen.toVarName(PerlClientCodegen.java:279)
	at org.openapitools.codegen.languages.PerlClientCodegen.toParamName(PerlClientCodegen.java:292)
	at org.openapitools.codegen.DefaultCodegen.toArrayModelParamName(DefaultCodegen.java:795)
	at org.openapitools.codegen.DefaultCodegen.fromRequestBody(DefaultCodegen.java:4395)
	at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2329)
	at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:910)
... 5 more

Copy link
Member

@wing328 wing328 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@jmini jmini merged commit 14ab3d7 into OpenAPITools:master Jul 29, 2018
@jmini jmini deleted the issue677 branch July 29, 2018 11:11
@jmini jmini changed the title Consider cases where complexType is null [all] Fix NullPointerException with list of simple types Jul 29, 2018
@jmini jmini added this to the 3.2.0 milestone Jul 29, 2018
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Perl] Generating fails with exception
2 participants