MCPcopy Index your code
hub / github.com/github/copilot-sdk / collectSchemaReferencedDefinitionNames

Function collectSchemaReferencedDefinitionNames

scripts/codegen/utils.ts:1324–1366  ·  view source on GitHub ↗
(
    schemas: Iterable<JSONSchema7 | null | undefined>,
    definitionCollections: DefinitionCollections
)

Source from the content-addressed store, hash-verified

1322}
1323
1324export function collectSchemaReferencedDefinitionNames(
1325 schemas: Iterable<JSONSchema7 | null | undefined>,
1326 definitionCollections: DefinitionCollections
1327): Set<string> {
1328 const definitions = collectDefinitions({
1329 definitions: definitionCollections.definitions ?? {},
1330 $defs: definitionCollections.$defs ?? {},
1331 });
1332 const reachable = new Set<string>();
1333 const visiting = new Set<string>();
1334
1335 const visitDefinition = (name: string, ref?: string): void => {
1336 if (reachable.has(name) || visiting.has(name)) return;
1337 const definition = ref ? resolveRef(ref, definitionCollections) : definitions[name];
1338 if (definition === undefined || typeof definition !== "object" || definition === null) return;
1339
1340 visiting.add(name);
1341 reachable.add(name);
1342 visitSchema(definition);
1343 visiting.delete(name);
1344 };
1345
1346 const visitSchema = (value: unknown): void => {
1347 if (!value || typeof value !== "object") return;
1348 if (Array.isArray(value)) {
1349 for (const item of value) visitSchema(item);
1350 return;
1351 }
1352
1353 const record = value as Record<string, unknown>;
1354 if (typeof record.$ref === "string") {
1355 const localRef = parseLocalDefinitionRef(record.$ref);
1356 if (localRef) visitDefinition(localRef, record.$ref);
1357 }
1358 for (const child of Object.values(record)) visitSchema(child);
1359 };
1360
1361 for (const schema of schemas) {
1362 visitSchema(schema);
1363 }
1364
1365 return reachable;
1366}
1367
1368export function collectRpcMethodReferencedDefinitionNames(
1369 methods: Iterable<RpcMethod>,

Calls 2

collectDefinitionsFunction · 0.85
visitSchemaFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…