OpenAPITools / OpenAPITools/openapi-generator

[BUG][Go] Parameter with free-form object type throws NullPointerException

Open
#11,283 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

5.3.1

OpenAPI declaration file content or url
"/settings/integration": {
  "put": {
    "description": "Create or update an instance of an integration",
    "summary": "Create/update an integration instance",
    "operationId": "createUpdateIntegrationInstance",
    "parameters": [
      {
        "name": "CreateIntegrationRequest",
        "in": "body",
        "schema": {
          "type": "object"
        }
      }
    ],
    "responses": {
      "200": {
        "description": "IntegrationWrapper",
        "schema": {
          "$ref": "#/definitions/IntegrationWrapper"
        }
      }
    }
  }
}
Generation Details
Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'Default'
	at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:682)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:907)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:441)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:541)
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:492)
	at org.openapitools.codegen.languages.GoClientCodegen.postProcessOperationsWithModels(GoClientCodegen.java:460)
	at org.openapitools.codegen.DefaultGenerator.processOperations(DefaultGenerator.java:1224)
	at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:585)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in org.openapitools.codegen.languages.GoClientCodegen.java at constructExampleCode, especially around line 541, following the call from postProcessOperationsWithModels. Reproduce generation with the provided OpenAPI declaration and verify that the Go client is generated without the reported NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.