[BUG][GO] unused import "time"
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 go
generator generates unused import "time"
statements which makes compilation impossible.
This happens when the model has anyOf, oneOf or allOf statements. import "time"
is created when any of the vars
of a model is of type time.Time
. But this is wrong as model.vars
includes all vars from anyOf, oneOf or allOf IF the model itself does not have any properties. This leads to imports which are actually required by referenced structs in other files
Here the nested Files struct causes the parent to add import "time"
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
Minimal spec:
https://gist.github.com/NickUfer/dcf51a1a86b06b5a9924753e12e6c437
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
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/13833