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

Function resolveObjectSchema

scripts/codegen/utils.ts:1106–1151  ·  view source on GitHub ↗
(
    schema: JSONSchema7 | null | undefined,
    definitions: DefinitionCollections | undefined
)

Source from the content-addressed store, hash-verified

1104}
1105
1106export function resolveObjectSchema(
1107 schema: JSONSchema7 | null | undefined,
1108 definitions: DefinitionCollections | undefined
1109): JSONSchema7 | undefined {
1110 const resolved = resolveSchema(schema, definitions) ?? schema ?? undefined;
1111 if (!resolved) return undefined;
1112 const resolvedHasObjectShape = hasObjectShape(resolved);
1113
1114 if (resolved.allOf) {
1115 const objectSchemas: JSONSchema7[] = [];
1116 if (resolvedHasObjectShape) {
1117 objectSchemas.push(resolved);
1118 }
1119
1120 for (const item of resolved.allOf) {
1121 if (typeof item !== "object") continue;
1122 const objectSchema = resolveObjectSchema(item as JSONSchema7, definitions);
1123 if (!objectSchema) continue;
1124 objectSchemas.push(objectSchema);
1125 }
1126
1127 return mergeObjectSchemas(objectSchemas) ?? resolved;
1128 }
1129
1130 const singleBranch = (resolved.anyOf ?? resolved.oneOf)
1131 ?.filter((item): item is JSONSchema7 => {
1132 if (!item || typeof item !== "object") return false;
1133 const s = item as JSONSchema7;
1134 // Filter out null types and `{ not: {} }` (Zod's representation of "nothing" in optional anyOf)
1135 if (s.type === "null") return false;
1136 if (isEmptyNotSchema(s)) return false;
1137 return true;
1138 });
1139 if (singleBranch && singleBranch.length === 1) {
1140 const objectSchema = resolveObjectSchema(singleBranch[0], definitions);
1141 if (!objectSchema) return resolved;
1142 if (resolvedHasObjectShape) {
1143 return mergeObjectSchemas([resolved, objectSchema]) ?? objectSchema;
1144 }
1145 return objectSchema;
1146 }
1147
1148 if (resolvedHasObjectShape) return resolved;
1149
1150 return resolved;
1151}
1152
1153export function getSessionEventVariantSchemas(
1154 schema: JSONSchema7,

Callers 15

tryEmitRustUnionFunction · 0.85
resolveRustTypeFunction · 0.85
extractEventVariantsFunction · 0.85
asGeneratedObjectSchemaFunction · 0.85
emitNamespaceMethodFunction · 0.85
getMethodParamsSchemaFunction · 0.85
extractEventVariantsFunction · 0.85
getVariantSchemaFunction · 0.85
emitRpcClassFunction · 0.85
getMethodParamsSchemaFunction · 0.85

Calls 5

resolveSchemaFunction · 0.85
hasObjectShapeFunction · 0.85
mergeObjectSchemasFunction · 0.85
isEmptyNotSchemaFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…