MCPcopy
hub / github.com/dosco/graphjin / expandSpecConfig

Function expandSpecConfig

core/openapi/loader.go:193–217  ·  view source on GitHub ↗

expandSpecConfig walks SpecConfig and applies env-var expansion to every credential-bearing string. Maps and slices are copied so the caller's configs aren't mutated.

(in SpecConfig)

Source from the content-addressed store, hash-verified

191// every credential-bearing string. Maps and slices are copied so the
192// caller's configs aren't mutated.
193func expandSpecConfig(in SpecConfig) SpecConfig {
194 out := in
195 out.BaseURL = expandEnv(in.BaseURL)
196 out.Auth = expandAuthConfig(in.Auth)
197 if len(in.Joins) > 0 {
198 out.Joins = make(map[string]JoinConfig, len(in.Joins))
199 for k, v := range in.Joins {
200 out.Joins[k] = v
201 }
202 }
203 if len(in.Operations) > 0 {
204 out.Operations = make(map[string]OperationOverride, len(in.Operations))
205 for k, v := range in.Operations {
206 if len(v.Defaults) > 0 {
207 expanded := make(map[string]string, len(v.Defaults))
208 for dk, dv := range v.Defaults {
209 expanded[dk] = expandEnv(dv)
210 }
211 v.Defaults = expanded
212 }
213 out.Operations[k] = v
214 }
215 }
216 return out
217}
218
219func expandAuthConfig(in AuthConfig) AuthConfig {
220 out := in

Callers 2

LoadFunction · 0.85

Calls 2

expandEnvFunction · 0.85
expandAuthConfigFunction · 0.85

Tested by 1