(node: Record<string, unknown> | undefined)
| 520 | */ |
| 521 | export function fixNullableRequiredRefsInApiSchema(schema: ApiSchema): ApiSchema { |
| 522 | function walkApiNode(node: Record<string, unknown> | undefined): Record<string, unknown> | undefined { |
| 523 | if (!node) return undefined; |
| 524 | const result: Record<string, unknown> = {}; |
| 525 | for (const [key, value] of Object.entries(node)) { |
| 526 | if (isRpcMethod(value)) { |
| 527 | const method = value as RpcMethod; |
| 528 | result[key] = { |
| 529 | ...method, |
| 530 | params: method.params ? normalizeNullableRequiredRefs(method.params) : method.params, |
| 531 | result: method.result ? normalizeNullableRequiredRefs(method.result) : method.result, |
| 532 | }; |
| 533 | } else if (typeof value === "object" && value !== null) { |
| 534 | result[key] = walkApiNode(value as Record<string, unknown>); |
| 535 | } else { |
| 536 | result[key] = value; |
| 537 | } |
| 538 | } |
| 539 | return result; |
| 540 | } |
| 541 | |
| 542 | function normalizeDefs(defs: Record<string, JSONSchema7Definition> | undefined): Record<string, JSONSchema7Definition> | undefined { |
| 543 | if (!defs) return undefined; |
no test coverage detected
searching dependent graphs…