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
0.45.0-rc44 - the absolute most bleeding-edge version of the CLI
Generator Version
0.23.5 - observed in fern-go-fiber and fern-go-model
Describe the Bug
When defining an API spec with a timestamp type on an undiscriminated union, I observed the latest version of the generator for fern-go-fiber (and fern-go-model in testing) acting up on the Go source code it generated:
> fern generate
# (snip deprecations)
[api]: ✓ All checks passed
┌─
[api]: fernapi/fern-go-fiber failed to parse Go code: logs\types.go:676:55: expected ';', found '{' (and 3 more errors)
[api]: fernapi/fern-openapi Downloaded to <>\models\openapi
┌─
│ ✓ fernapi/fern-openapi
│ x fernapi/fern-go-fiber
└─
Additional Context
After doing some magic to get local development working again, I did a deep dive:
Instrumented additional logging into generator/go with some fmt.Errorf wraps to drill down to the generated source (where this error is emitted, in generators/go/internal/generator/file_writer.go)
Added some printing of the troublesome generated source
Observed the following, since up to this point I had no idea what was going on:
> ..\..\fern\generators\go\build\fern-go-fiber.exe config.json
failed to run: failed to parse Go code: logs\types.go:676:55: expected ';', found '{' (and 3 more errors); source:
=-=
672: }
674: return json.Marshal(l.String)
675: }
676: if l.typ == "Timestamp"|| l.Timestamp != time.Time{} {
^
677: return json.Marshal(l.Timestamp)
678: }
679: return nil, fmt.Errorf("type %T does not include a non-empty union type", l)
680: }
Aha, that's a golang parser no-no!
Found the generator source that controls this:
Looks like it's in VisitUndiscriminatedUnion...
To be safe, I wrap each full if statement in parentheses to resolve -> and a subsequent local build + execution shows successful generation.
I made the needed changes to fix this on a fork, will make a PR shortly stemming from this issue! I will leave the improved error / generated source logging changes as a separate commit to let them be cherry-picked out.
The text was updated successfully, but these errors were encountered:
dannysheridan
changed the title
[Bug] Timestamp type causes "expected ';', found '{'" syntax error in generated types
Timestamp type causes "expected ';', found '{'" syntax error in generated types
Dec 1, 2024
CLI Version
0.45.0-rc44
- the absolute most bleeding-edge version of the CLIGenerator Version
0.23.5
- observed infern-go-fiber
andfern-go-model
Describe the Bug
When defining an API spec with a timestamp type on an undiscriminated union, I observed the latest version of the generator for
fern-go-fiber
(andfern-go-model
in testing) acting up on the Go source code it generated:Additional Context
After doing some magic to get local development working again, I did a deep dive:
generator/go
with somefmt.Errorf
wraps to drill down to the generated source (where this error is emitted, ingenerators/go/internal/generator/file_writer.go
)VisitUndiscriminatedUnion
...I made the needed changes to fix this on a fork, will make a PR shortly stemming from this issue! I will leave the improved error / generated source logging changes as a separate commit to let them be cherry-picked out.
The text was updated successfully, but these errors were encountered: