Skip to content

Conversation

@jamietanna
Copy link
Member

@jamietanna jamietanna commented Dec 18, 2023

The current approach doesn't often work when generating types that are
in external packages, unless that package is also a strict server's
definition, which isn't always the case.


Noticed while working on #1378

@jamietanna jamietanna marked this pull request as draft December 18, 2023 12:14
@jamietanna jamietanna force-pushed the feature/external-ref-strict branch from 875db16 to 71813ff Compare December 18, 2023 12:22
@jamietanna jamietanna marked this pull request as ready for review December 18, 2023 12:22
@jamietanna jamietanna force-pushed the feature/external-ref-strict branch from 71813ff to 520ad55 Compare December 18, 2023 12:33
The current approach doesn't often work when generating types that are
in external packages, unless that package is also a strict server's
definition, which isn't always the case.
As part of follow-up changes, we'll need it, and it's handy to keep this
consistent with other types that have this.
In the case that we're referencing a type defined in an external
package, using an alias here results in build errors i.e.:

  ./api.gen.go:93:7: cannot define new methods on non-local type common.TypeNameHere

Instead, we can make sure we only alias when there's not an external
reference in use, using the new `Schema.IsExternalRef` function.
@jamietanna jamietanna force-pushed the feature/external-ref-strict branch from 520ad55 to 1ef78fc Compare January 19, 2024 10:57
@jamietanna jamietanna added bug Something isn't working area:external-refs Anything related to external references (referencing other file(s) within a spec) labels Jan 25, 2024
@jamietanna jamietanna merged commit 390058d into master Jan 25, 2024
@jamietanna jamietanna deleted the feature/external-ref-strict branch May 5, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:external-refs Anything related to external references (referencing other file(s) within a spec) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants