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

Function mergeObjectSchemas

scripts/codegen/utils.ts:1066–1104  ·  view source on GitHub ↗
(schemas: JSONSchema7[])

Source from the content-addressed store, hash-verified

1064}
1065
1066function mergeObjectSchemas(schemas: JSONSchema7[]): JSONSchema7 | undefined {
1067 const mergedProperties: Record<string, JSONSchema7Definition> = {};
1068 const mergedRequired = new Set<string>();
1069 const merged: JSONSchema7 = {
1070 type: "object",
1071 };
1072 let hasShape = false;
1073
1074 for (const objectSchema of schemas) {
1075 if (!merged.title && objectSchema.title) {
1076 merged.title = objectSchema.title;
1077 }
1078 if (!merged.description && objectSchema.description) {
1079 merged.description = objectSchema.description;
1080 }
1081 if (objectSchema.properties) {
1082 Object.assign(mergedProperties, objectSchema.properties);
1083 hasShape = true;
1084 }
1085 if (objectSchema.required) {
1086 for (const name of objectSchema.required) {
1087 mergedRequired.add(name);
1088 }
1089 }
1090 if (objectSchema.additionalProperties !== undefined) {
1091 merged.additionalProperties = objectSchema.additionalProperties;
1092 hasShape = true;
1093 }
1094 }
1095
1096 if (!hasShape) return undefined;
1097 if (Object.keys(mergedProperties).length > 0) {
1098 merged.properties = mergedProperties;
1099 }
1100 if (mergedRequired.size > 0) {
1101 merged.required = [...mergedRequired];
1102 }
1103 return merged;
1104}
1105
1106export function resolveObjectSchema(
1107 schema: JSONSchema7 | null | undefined,

Callers 1

resolveObjectSchemaFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…