You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's the actual output vs expected output?
In the generated model_foo.go, we have
import (
"encoding/json"
)
But should have
import (
"encoding/json"
"time"
)
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I found a case where the generated Go code doesn't compile, it is missing an import of the time package. I think it's due to an incorrect implementation of polymorphism.
openapi-generator version
$ docker run --rm openapitools/openapi-generator-cli:latest version
7.10.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.0info:
version: '1.0.0'title: 'FooBar Service'paths: {}components:
schemas:
Foo:
type: objectanyOf: [] # doesn't need to contain anything, the object's properties are dropped due to the presence of anyOfproperties:
bar:
format: date-timetype: string
Generation Details
I'm using
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate \
--input-spec /local/go-time-import.yaml \
--generator-name go \
--additional-properties "withGoMod=false" \
--package-name gen \
--output /local/gen
[...]
gen/model_foo.go:22:7: undefined: time
gen/model_foo.go:43:24: undefined: time
gen/model_foo.go:45:11: undefined: time
gen/model_foo.go:53:28: undefined: time
gen/model_foo.go:70:24: undefined: time
Bug Report Checklist
In the generated
model_foo.go
, we haveDescription
I found a case where the generated Go code doesn't compile, it is missing an import of the time package. I think it's due to an incorrect implementation of polymorphism.
openapi-generator version
OpenAPI declaration file content or url
Generation Details
I'm using
Steps to reproduce
If you run https://gist.github.com/perhallgren/d2af2441d7c265a06407313b064f68d6, you get:
Related issues/PRs
Suggest a fix
I'm working on #19958, with a fix that seems to solve the problem I am having.
The text was updated successfully, but these errors were encountered: