MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / GoSchemaImports

Function GoSchemaImports

pkg/codegen/codegen.go:1363–1399  ·  view source on GitHub ↗
(schemas ...*openapi3.SchemaRef)

Source from the content-addressed store, hash-verified

1361}
1362
1363func GoSchemaImports(schemas ...*openapi3.SchemaRef) (map[string]goImport, error) {
1364 res := map[string]goImport{}
1365 for _, sref := range schemas {
1366 if sref == nil {
1367 return nil, nil
1368 }
1369
1370 if gi, err := ParseGoImportExtension(sref); err != nil {
1371 return nil, err
1372 } else if gi != nil {
1373 res[gi.String()] = *gi
1374 }
1375
1376 if sref.Value == nil || IsGoTypeReference(sref.Ref) {
1377 continue
1378 }
1379 schemaVal := sref.Value
1380
1381 t := schemaVal.Type
1382 if t.Slice() == nil || t.Is("object") {
1383 for _, v := range schemaVal.Properties {
1384 imprts, err := GoSchemaImports(v)
1385 if err != nil {
1386 return nil, err
1387 }
1388 maps.Copy(res, imprts)
1389 }
1390 } else if t.Is("array") {
1391 imprts, err := GoSchemaImports(schemaVal.Items)
1392 if err != nil {
1393 return nil, err
1394 }
1395 maps.Copy(res, imprts)
1396 }
1397 }
1398 return res, nil
1399}
1400
1401func GetSchemaImports(schemas map[string]*openapi3.SchemaRef, excludeSchemas []string) (map[string]goImport, error) {
1402 res := map[string]goImport{}

Callers 5

OperationSchemaImportsFunction · 0.85
GetSchemaImportsFunction · 0.85
GetRequestBodiesImportsFunction · 0.85
GetResponsesImportsFunction · 0.85
GetParametersImportsFunction · 0.85

Calls 3

ParseGoImportExtensionFunction · 0.85
IsGoTypeReferenceFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected