massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / node_modules / ajv / lib / compile / resolve.ts
index b4ee22b12c441679b0c51c8ca4578cc4831ad5f1..9031e0390a98405fc85f39b458f8c6da3828529d 100644 (file)
@@ -89,11 +89,12 @@ export function resolveUrl(baseId: string, id: string): string {
 
 const ANCHOR = /^[a-z_][-a-z0-9._]*$/i
 
-export function getSchemaRefs(this: Ajv, schema: AnySchema): LocalRefs {
+export function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
   if (typeof schema == "boolean") return {}
-  const schemaId = normalizeId(schema.$id)
-  const baseIds: {[JsonPtr in string]?: string} = {"": schemaId}
-  const pathPrefix = getFullPath(schemaId, false)
+  const {schemaId} = this.opts
+  const schId = normalizeId(schema[schemaId] || baseId)
+  const baseIds: {[JsonPtr in string]?: string} = {"": schId}
+  const pathPrefix = getFullPath(schId, false)
   const localRefs: LocalRefs = {}
   const schemaRefs: Set<string> = new Set()
 
@@ -101,7 +102,7 @@ export function getSchemaRefs(this: Ajv, schema: AnySchema): LocalRefs {
     if (parentJsonPtr === undefined) return
     const fullPath = pathPrefix + jsonPtr
     let baseId = baseIds[parentJsonPtr]
-    if (typeof sch.$id == "string") baseId = addRef.call(this, sch.$id)
+    if (typeof sch[schemaId] == "string") baseId = addRef.call(this, sch[schemaId])
     addAnchor.call(this, sch.$anchor)
     addAnchor.call(this, sch.$dynamicAnchor)
     baseIds[jsonPtr] = baseId