// TODO improve the guidance in this error if/when we better abstract over imports to generate
returnnil,fmt.Errorf("goimports added the following import statements to %s: \n\t%s\nRelying on goimports to find imports significantly slows down code generation. Either add these imports with an AST manipulation in cfg.ApplyFuncs, or set cfg.IgnoreDiscoveredImports to true",cfg.path,strings.Join(added,"\n\t"))
}
returnbyt,nil
}
// fixDataQuery extends the properties for the AllOf schemas when a DataQuery exists.
// deep/oapi-codegen library ignores the properties of the models and only ones have references.
// It doesn't apply this change https://github.com/grafana/thema/pull/154 since it modifies the
// vendor implementation, and we don't import it.
funcfixDataQuery(spec*openapi3.T)*openapi3.T{
for_,sch:=rangespec.Components.Schemas{
ifsch.Value!=nil&&len(sch.Value.AllOf)>0{
for_,allOf:=rangesch.Value.AllOf{
forn,p:=rangeallOf.Value.Properties{
sch.Value.Properties[n]=p
}
}
sch.Value.AllOf=nil
}
}
returnspec
}
// Almost all of the below imports are eliminated by dst transformers and calls
// to goimports - but if they're not present in the template, then the internal
// call to goimports that oapi-codegen makes will trigger a search for them,
// which can slow down codegen by orders of magnitude.