Skip to content

Commit d4ff763

Browse files
committed
Add override for _types.ScriptSource
Fixes an issue with bunch of unrelated types being pulled into the dependency tree because _types.ScriptSource is a union that includes SearchRequestBody which brings with it many other deps.
1 parent de751ca commit d4ff763

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

internal/generator/internal/codegen/generator.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ var overrides = map[string]string{
5050
// _types.Script, to be a string type instead of a struct. This is a
5151
// workaround solving issue:
5252
// https://github.com/andrewkroh/go-ingest-node/issues/15.
53-
"_types.Script": "string",
53+
"_types.Script": "string",
54+
"_types.ScriptSource": "string",
5455
}
5556

5657
// acronyms is a set of acronyms that should be capitalized in identifiers.
@@ -117,8 +118,15 @@ func New(model *spec.Model) *Generator {
117118
}
118119

119120
func (b *Generator) BuildCode(w io.Writer, typeSelector func(name, inherits spec.TypeName) bool) error {
121+
// Mark the overrides as visited dependencies so that those types and
122+
// their dependencies are not included in the generated code.
123+
deps := make(map[spec.TypeName]bool, len(overrides))
124+
for k := range overrides {
125+
parts := strings.SplitN(k, ".", 2)
126+
deps[spec.TypeName{Namespace: parts[0], Name: parts[1]}] = true
127+
}
128+
120129
selected := map[spec.TypeName]*spec.TypeDefinition{}
121-
deps := map[spec.TypeName]bool{}
122130

123131
for n, t := range b.allTypes {
124132
var name, inherits spec.TypeName

0 commit comments

Comments
 (0)