OpenAPITools / OpenAPITools/openapi-generator
[BUG][Go] undeclared name: isNil
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the provided Docker generation command with the models-only global property and confirm the undeclared isNil error. Then inspect the Go generator's model-only path and the utils generation change referenced in pull request #13843; done means generated models compile with isNil available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100