Created by: jmini
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 (closed)
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