(schema: JSONSchema7 | null | undefined)
| 453 | } |
| 454 | |
| 455 | export function getEnumValueDescriptions(schema: JSONSchema7 | null | undefined): EnumValueDescriptions | undefined { |
| 456 | if (!schema || typeof schema !== "object") return undefined; |
| 457 | |
| 458 | const rawDescriptions = (schema as Record<string, unknown>)["x-enumDescriptions"]; |
| 459 | if (!rawDescriptions || typeof rawDescriptions !== "object" || Array.isArray(rawDescriptions)) return undefined; |
| 460 | |
| 461 | const descriptions: EnumValueDescriptions = {}; |
| 462 | for (const [value, description] of Object.entries(rawDescriptions)) { |
| 463 | if (typeof description !== "string") continue; |
| 464 | |
| 465 | const trimmedDescription = description.trim(); |
| 466 | if (trimmedDescription.length > 0) { |
| 467 | descriptions[value] = trimmedDescription; |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | return Object.keys(descriptions).length > 0 ? descriptions : undefined; |
| 472 | } |
| 473 | |
| 474 | const INT32_MIN = -(2 ** 31); |
| 475 | const INT32_MAX = 2 ** 31 - 1; |
no outgoing calls
no test coverage detected
searching dependent graphs…