(schemas ...*openapi3.SchemaRef)
| 1361 | } |
| 1362 | |
| 1363 | func 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 | |
| 1401 | func GetSchemaImports(schemas map[string]*openapi3.SchemaRef, excludeSchemas []string) (map[string]goImport, error) { |
| 1402 | res := map[string]goImport{} |
no test coverage detected