fern-api / fern

Input OpenAPI. Output SDKs and Docs.
https://buildwithfern.com
Apache License 2.0
2.68k stars 151 forks source link

feat(go): Improve file layout for types #5173

Closed amckinney closed 1 week ago

amckinney commented 1 week ago

Overview

This makes changes in both the Fern CLI and the Go generator to improve the file layout of the Go SDK.

Implementation

This updates the IR's ServiceTypeReferenceInfo so that it now captures transitive types referenced from each service. Additionally, this simplifies and improves the Go SDK's file layout resolution according to the latest changes in the IR.

Effect

In combination, types can more accurately be placed according to the service they're used by whenever possible. The SDK still limits how many top-level files it can create for GitHub repository aesthetics - there is at most one file for every package we generate.

For large APIs, this reduces the size of the generated types.go file by ~50% and preserves backwards compatibility.

github-actions[bot] commented 1 week ago

🌿 Preview your docs: https://fern-preview-7704e2f5-0e9a-44e7-b306-ee15a5fcdabf.docs.buildwithfern.com/learn