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
Fix: Don't use type aliases with external references
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.
Copy file name to clipboardExpand all lines: pkg/codegen/templates/strict/strict-fiber-interface.tmpl
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@
48
48
type {{$receiverTypeName}} struct{ {{$ref}}{{.NameTagOrContentType}}Response }
49
49
{{end}}
50
50
{{else if and (not $hasHeaders) ($fixedStatusCode) (.IsSupported) -}}
51
-
type {{$receiverTypeName}} {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{if .Schema.IsRef}}={{end}} {{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
51
+
type {{$receiverTypeName}} {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{if and .Schema.IsRef (not .Schema.IsExternalRef)}}={{end}} {{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
52
52
{{else -}}
53
53
type {{$receiverTypeName}} struct {
54
54
Body {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
Copy file name to clipboardExpand all lines: pkg/codegen/templates/strict/strict-interface.tmpl
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@
50
50
type {{$receiverTypeName}} struct{ {{$ref}}{{.NameTagOrContentType}}Response }
51
51
{{end}}
52
52
{{else if and (not $hasHeaders) ($fixedStatusCode) (.IsSupported) -}}
53
-
type {{$receiverTypeName}} {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{if .Schema.IsRef}}={{end}} {{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
53
+
type {{$receiverTypeName}} {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{if and .Schema.IsRef (not .Schema.IsExternalRef)}}={{end}} {{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
54
54
{{else -}}
55
55
type {{$receiverTypeName}} struct {
56
56
Body {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
Copy file name to clipboardExpand all lines: pkg/codegen/templates/strict/strict-iris-interface.tmpl
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@
50
50
type {{$receiverTypeName}} struct{ {{$ref}}{{.NameTagOrContentType}}Response }
51
51
{{end}}
52
52
{{else if and (not $hasHeaders) ($fixedStatusCode) (.IsSupported) -}}
53
-
type {{$receiverTypeName}} {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{if .Schema.IsRef}}={{end}} {{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
53
+
type {{$receiverTypeName}} {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{if and .Schema.IsRef (not .Schema.IsExternalRef)}}={{end}} {{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
54
54
{{else -}}
55
55
type {{$receiverTypeName}} struct {
56
56
Body {{if eq .NameTag "Multipart"}}func(writer *multipart.Writer)error{{else if .IsSupported}}{{.Schema.TypeDecl}}{{else}}io.Reader{{end}}
0 commit comments