MCPcopy
hub / github.com/fastify/fast-json-stringify / mergeLocations

Function mergeLocations

index.js:490–512  ·  view source on GitHub ↗
(context, mergedSchemaId, mergedLocations)

Source from the content-addressed store, hash-verified

488}
489
490function mergeLocations (context, mergedSchemaId, mergedLocations) {
491 for (let i = 0, mergedLocationsLength = mergedLocations.length; i < mergedLocationsLength; i++) {
492 const location = mergedLocations[i]
493 const schema = location.schema
494 if (schema.$ref) {
495 mergedLocations[i] = resolveRef(context, location)
496 }
497 }
498
499 const mergedSchemas = []
500 for (const location of mergedLocations) {
501 const schema = cloneOriginSchema(context, location.schema, location.schemaId)
502 delete schema.$id
503
504 mergedSchemas.push(schema)
505 }
506
507 const mergedSchema = mergeSchemas(mergedSchemas)
508 const mergedLocation = new Location(mergedSchema, mergedSchemaId)
509
510 context.refResolver.addSchema(mergedSchema, mergedSchemaId)
511 return mergedLocation
512}
513
514function cloneOriginSchema (context, schema, schemaId) {
515 const clonedSchema = Array.isArray(schema) ? [] : {}

Callers 3

buildAllOfFunction · 0.85
buildOneOfFunction · 0.85
buildIfThenElseFunction · 0.85

Calls 4

resolveRefFunction · 0.85
cloneOriginSchemaFunction · 0.85
mergeSchemasFunction · 0.85
addSchemaMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…