[BUG][GO] generation of nil check for struct
Created by: NickUfer
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
The generator generates code like
if someStruct{} == nil {
// ...
Which is invalid as a struct can't be nil.
go build
output of my generated client:
[...]
./model_export_request.go:107:3: cannot use nil as type Files in return argument
./model_read_single_items_blogs_200_response.go:41:24: cannot convert nil to type ItemsBlogs
./model_read_single_items_blogs_200_response.go:51:24: cannot convert nil to type ItemsBlogs
./model_read_single_items_blogs_200_response.go:52:3: cannot use nil as type ItemsBlogs in return argument
./model_read_single_items_blogs_200_response.go:59:24: cannot convert nil to type ItemsBlogs
./model_read_single_items_blogs_200_response.go:73:12: cannot convert nil to type ItemsBlogs
[...]
openapi-generator version
6.2.0
OpenAPI declaration file content or url
This spec is generated by https://github.com/directus/directus
https://gist.github.com/NickUfer/3c004a00df5ca1420b9949613ddaeb61
Generation Details
config file:
disallowAdditionalPropertiesIfNotPresent: true
packageName: directusclient
generateInterfaces: true
structPrefix: true
enumClassPrefix: true
cmd:
generate -i /tmp/oas.yaml -g go -o "/tmp/directusclient" -c /tmp/go.yml