(schemaPath: string)
| 55 | * @returns {string[]} an array containing only non-schema-specific segments |
| 56 | */ |
| 57 | export const toDataPathSegments = (schemaPath: string): string[] => { |
| 58 | const s = schemaPath |
| 59 | .replace(/(anyOf|allOf|oneOf)\/[\d]+\//g, '') |
| 60 | .replace(/(then|else)\//g, ''); |
| 61 | const segments = s.split('/'); |
| 62 | |
| 63 | const decodedSegments = segments.map(decode); |
| 64 | |
| 65 | const startFromRoot = decodedSegments[0] === '#' || decodedSegments[0] === ''; |
| 66 | const startIndex = startFromRoot ? 2 : 1; |
| 67 | return range(startIndex, decodedSegments.length, 2).map( |
| 68 | (idx) => decodedSegments[idx] |
| 69 | ); |
| 70 | }; |
| 71 | |
| 72 | /** |
| 73 | * Convert a schema path (i.e. JSON pointer) to a data path. |
no outgoing calls
no test coverage detected
searching dependent graphs…