Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #12357
Closed
Open
Issue created May 13, 2022 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG] [Golang][Client] java.lang.NullPointerException: Cannot read field "name" because "codegenModel" is null

Created by: okhowang

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

run generator got exception with yaml

Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'Default'
	at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:668)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:895)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:449)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException: Cannot read field "name" because "codegenModel" is null
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:660)
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:683)
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:639)
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:595)
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:693)
	at org.openapitools.codegen.languages.GoClientCodegen.constructExampleCode(GoClientCodegen.java:565)
	at org.openapitools.codegen.languages.GoClientCodegen.postProcessOperationsWithModels(GoClientCodegen.java:487)
	at org.openapitools.codegen.DefaultGenerator.processOperations(DefaultGenerator.java:1215)
	at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:572)
	... 4 more

Process finished with exit code 1
openapi-generator version

v5.4.0 master[02f16267]

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  version: 0.0.1
  title: example
paths:
  /:
    post:
      summary: demo
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Model'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: string

components:
  schemas:
    Item:
      oneOf:
        - type: string
        - type: integer
    Model:
      type: object
      required:
        - Items
      properties:
        Items:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/Item'
Generation Details
generate -g go -i test\openapi.yaml -o test\go
Steps to reproduce
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking