Skip to content
New issue

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

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

Already on GitHub? # to your account

[go-server] Null Pointer exception when request body schema is array #373

Closed
etherealjoy opened this issue Jun 21, 2018 · 0 comments
Closed

Comments

@etherealjoy
Copy link
Contributor

etherealjoy commented Jun 21, 2018

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

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
@etherealjoy etherealjoy changed the title [go-server] Null Pointer exception when body schema is array of maps [go-server] Null Pointer exception when request body schema is array of maps Jun 21, 2018
@etherealjoy etherealjoy changed the title [go-server] Null Pointer exception when request body schema is array of maps [go-server] Null Pointer exception when request body schema is array Jun 21, 2018
@etherealjoy etherealjoy reopened this Jul 2, 2018
@jmini jmini closed this as completed in #377 Jul 3, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant