| 308 | * key, which matches the trailing segment of a `#/components/schemas/<name>` |
| 309 | * reference. */ |
| 310 | export const indexSchemas = (structure: SpecStructure): ReadonlyMap<string, ByteRange> => { |
| 311 | const index = new Map<string, ByteRange>(); |
| 312 | for (const range of structure.schemas) { |
| 313 | const line = lineAt(structure.text, range.start, range.end); |
| 314 | if (!line) continue; |
| 315 | const name = keyNameAt(structure.text, range.start, line.lineEnd); |
| 316 | if (name) index.set(name, range); |
| 317 | } |
| 318 | return index; |
| 319 | }; |
| 320 | |
| 321 | /** Decode a `#/components/schemas/<segment>` name segment. Schema names are raw |
| 322 | * YAML keys, so only JSON-pointer tilde escaping can appear (no `%`-encoding |