fix(plugin): normalize bare schema refs
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -47,6 +47,14 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
function normalizeJsonSchemaRef(value: string): string {
|
||||
if (value.startsWith("#") || value.includes(":") || value.startsWith("/")) {
|
||||
return value
|
||||
}
|
||||
|
||||
return `#/$defs/${value}`
|
||||
}
|
||||
|
||||
export function sanitizeJsonSchema(value: unknown, depth = 0, isPropertyName = false): unknown {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((item) => sanitizeJsonSchema(item, depth + 1, false))
|
||||
@@ -67,6 +75,11 @@ export function sanitizeJsonSchema(value: unknown, depth = 0, isPropertyName = f
|
||||
continue
|
||||
}
|
||||
|
||||
if (!isPropertyName && key === "$ref" && typeof nestedValue === "string") {
|
||||
sanitized[key] = normalizeJsonSchemaRef(nestedValue)
|
||||
continue
|
||||
}
|
||||
|
||||
const childIsPropertyName = key === "properties" && !isPropertyName
|
||||
sanitized[key] = sanitizeJsonSchema(nestedValue, depth + 1, childIsPropertyName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user