MCPcopy Index your code
hub / github.com/fastify/fast-json-stringify / cloneOriginSchema

Function cloneOriginSchema

index.js:514–544  ·  view source on GitHub ↗
(context, schema, schemaId)

Source from the content-addressed store, hash-verified

512}
513
514function cloneOriginSchema (context, schema, schemaId) {
515 const clonedSchema = Array.isArray(schema) ? [] : {}
516
517 if (
518 schema.$id !== undefined &&
519 schema.$id.charAt(0) !== '#'
520 ) {
521 schemaId = schema.$id
522 }
523
524 const mergedSchemaRef = context.mergedSchemasIds.get(schema)
525 if (mergedSchemaRef) {
526 context.mergedSchemasIds.set(clonedSchema, mergedSchemaRef)
527 }
528
529 for (const key in schema) {
530 let value = schema[key]
531
532 if (key === '$ref' && typeof value === 'string' && value.charAt(0) === '#') {
533 value = schemaId + value
534 }
535
536 if (typeof value === 'object' && value !== null) {
537 value = cloneOriginSchema(context, value, schemaId)
538 }
539
540 clonedSchema[key] = value
541 }
542
543 return clonedSchema
544}
545
546function toJSON (variableName) {
547 return `(${variableName} && typeof ${variableName}.toJSON === 'function')

Callers 1

mergeLocationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…