(idKey: string, schema: JSONSchema7)
| 99 | } |
| 100 | |
| 101 | export function getItemSchemaFromRes(idKey: string, schema: JSONSchema7): JSONSchema7 | null { |
| 102 | const objectKeys = idKey |
| 103 | .replace(/\[]\./g, '.0.') |
| 104 | .split('.') |
| 105 | .filter((key) => key) |
| 106 | |
| 107 | let iterationSchema: JSONSchema7 = schema |
| 108 | let resultSchema: JSONSchema7 = schema |
| 109 | for (const key of objectKeys) { |
| 110 | if (key.toString() === '0' && iterationSchema.items) { |
| 111 | iterationSchema = iterationSchema.items as JSONSchema7 |
| 112 | } else if (iterationSchema.properties?.[key]) { |
| 113 | resultSchema = iterationSchema |
| 114 | iterationSchema = iterationSchema.properties[key] as JSONSchema7 |
| 115 | } else { |
| 116 | return null |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | return resultSchema |
| 121 | } |
no outgoing calls
no test coverage detected