(context, location)
| 59 | } |
| 60 | |
| 61 | function resolveRef (context, location) { |
| 62 | const ref = location.schema.$ref |
| 63 | |
| 64 | let hashIndex = ref.indexOf('#') |
| 65 | if (hashIndex === -1) { |
| 66 | hashIndex = ref.length |
| 67 | } |
| 68 | |
| 69 | const schemaId = ref.slice(0, hashIndex) || location.schemaId |
| 70 | const jsonPointer = ref.slice(hashIndex) || '#' |
| 71 | |
| 72 | const schema = context.refResolver.getSchema(schemaId, jsonPointer) |
| 73 | if (schema === null) { |
| 74 | throw new Error(`Cannot find reference "${ref}"`) |
| 75 | } |
| 76 | |
| 77 | const newLocation = new Location(schema, schemaId, jsonPointer) |
| 78 | if (schema.$ref !== undefined) { |
| 79 | return resolveRef(context, newLocation) |
| 80 | } |
| 81 | |
| 82 | return newLocation |
| 83 | } |
| 84 | |
| 85 | function getMergedLocation (context, mergedSchemaId) { |
| 86 | const mergedSchema = context.refResolver.getSchema(mergedSchemaId, '#') |
no outgoing calls
no test coverage detected
searching dependent graphs…