[go-server] Null Pointer exception when request body schema is array
Created by: etherealjoy
Description
When the body of a request is an array NPE occurs
Exception: null
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:934)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:828)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:460)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:786)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:315)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:58)
Caused by: java.lang.NullPointerException
at org.openapitools.codegen.languages.AbstractGoCodegen.toVarName(AbstractGoCodegen.java:148)
at org.openapitools.codegen.languages.AbstractGoCodegen.toParamName(AbstractGoCodegen.java:181)
at org.openapitools.codegen.DefaultCodegen.toArrayModelParamName(DefaultCodegen.java:760)
at org.openapitools.codegen.DefaultCodegen.fromRequestBody(DefaultCodegen.java:4214)
at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2198)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:902)
... 5 more
openapi-generator version
master
OpenAPI declaration file content or url
---
# This is a sample Swagger spec
swagger: "2.0"
info:
description: Container Application Model Description
version: 1.0.0
title: ContainerApplication
host: localhost:32000
basePath: /api/v1.0
schemes:
- http
tags:
- name: ApplicationEndpointTest
x-displayName: "ApplicationEndpointTest"
description: |
"Test of endpoints "
paths:
/default/EndpointTest:
post:
tags:
- ApplicationEndpointTest
description: "post a request"
operationId: callEndpoint
consumes:
- application/json
parameters:
- name: "requestList"
in: "body"
description: "Requests to post"
required: true
schema:
$ref: "#/definitions/listitems"
responses:
200:
description: "Successful response"
404:
description: "The request was not successfully executed."
definitions:
listitems :
description: "list of items"
type: array
items:
type: "string"
Command line used for generation
java -jar ~/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ./api.yaml -o ./gengo-server -g go-server