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
  • #13893
Closed
Open
Issue created Nov 02, 2022 by Administrator@rootContributor

[BUG][Go] undeclared name: isNil

Created by: jonrosner

Description

When generating Go structs with the latest docker container, a function isNil is used in the code but not generated.

openapi-generator version

v6.2.1

latest docker container (IMAGE ID: 0f04bb22fe23)

OpenAPI declaration file content or URL

Every file depends on this function.

Generation Details
func (o *MyObject) GetField() string {
	if o == nil || isNil(o.Field) {
		var ret string
		return ret
	}
	return *o.Field
}

Note that isNil(o.Field)

Steps to reproduce
$ docker run --rm -v \"${PWD}:/local\" \
	openapitools/openapi-generator-cli:latest  generate \
	-i openapi.yaml \
	-g go -o ${PWD}/gen/openapi \
	--global-property models,modelDocs=false \
	--additional-properties packageName=openapi"
Suggest a fix

Seems to be related to this MR: https://github.com/OpenAPITools/openapi-generator/pull/13843/files#diff-f85b9f51529f9922081dd92244891f831a26e126f4e27dd53bdaa03c7d55456c

My guess would be that because I only generate the models, this "utils" is not generated. So a fix would be to generate this utils anyway, even if only models are to be generated.

Assignee
Assign to
Time tracking